jeudi 17 septembre 2015

How to select multiple rows of html table and write those selected rows to mysql table?

i am populating rows of html table with some data as shown in code below ! I want to allow user to select multiple rows of this html table (for example using checkboxes but don't know to utilize checkbox in this case) and then i want to add submit button so that user write ONly the selected html table rows to mysql table!(write each rows of html table to a separate mysql table row)

How i should allow user select html table rows and how to write data of multiple html table rows to mysql ?

<?
$postData_value = $_POST['postData'];
$pieces = explode("\n", $postData_value); // make an array out of curl return value
$pieces = array_map('trim', $pieces); // remove unnecessary space
$pieces = array_chunk($pieces, 2); // group them by two's

?>

<table id="test" cellspacing="0" border="1">
        <tr>

         <th>variable1 title1</th>
         <th>variable2 title2</th>
         <th>variable3 title3</th>
         <th>variable4 title4</th>
         <th>variable5 title5</th>
         <th>variable6 title6</th>
         <th>variable7 title7</th>

        </tr>

<?
foreach($pieces as $key => $value){
                 .....
                 .....
                 .....

       echo ("<tr><td>$variable1</td>");
       echo ("<td>$variable2</td>");
       echo ("<td>$variable3</td>");
       echo ("<td>$variable4</td>");
       echo ("<td>$variable5</td>");
       echo ("<td>$variable6</td>");
       echo ("<td>$variable7</td></tr>");

}

?>

</table>




Aucun commentaire:

Enregistrer un commentaire