php - Obtaining checkbox values for n number of rows -
i'm trying implement bulk action functionality data displayed sql database on webpage. i've echoed out data html format, , i'm trying add checkbox feature user can select number of rows , perform bulk action them choosing value dropdown, e.g. delete- , selected values deleted database. i'm stumbling bit though obtaining selected checkbox values once perform action button submitted. i've put attempt @ code below- i'm getting invalid foreach argument provided error message. i'm has input loop.
any appreciated!
//establish connection database: require 'db.php'; $query = mysql_query("select * names", $conn); echo "<tr>"; //echo results while rows of data remain... while ($row = mysql_fetch_array($query)) { echo '<tr><td>' . $row['name'] . '</td>'; echo '<td><input type="checkbox" name="checked[' . $row['name'] . ']" value="' . $row['name'] .'"></td>'; } ?> </tr> </table> </div> </body> </html> <? if (isset($_post['perform_action'])) { //check checkbox values foreach ($_post['checked'] $check) { echo $check; } //do values if ($_post['bulk_action'] == 'delete') { echo "you chose delete"; }
if (isset($_post['perform_action'])) { $query = mysql_query("select * names", $conn); while ($row = mysql_fetch_array($query)) { if (isset($_post["checked".$row['name']])){ //hear can checked checkbox } } }
Comments
Post a Comment