MargateSteve Posted November 28, 2011 Share Posted November 28, 2011 I recently got some help over in the PHP Coding forum to help edit multiple records as selected with checkboxes. Everything works fine as standard but I have thrown another spanner in the works that, as I think it is javascript related, I have not got a clue how to resolve. I have added the tablesorter script which allows me to, well, sort tables! The sorting part works fine but once I have used it, it then will not pass the checkbox values onto the next page/script. The page in question is HERE. It is on a non-production database so it is fine for people to actually test it. If I try to pass the records before sorting anything it works perfectly. However, as soon as I have clicked to sort any column, even one that is already sorted in the right order, it will not pass any checkbox values. However, after sorting, if I try to edit one record, via the pencil icon on the page, it works perfectly. This suggests to me that something happens during the javascript process that stops the values being passed as an array. The link to the script itself is http://autobahn.tablesorter.com/jquery.tablesorter.js. The code I have used is INITIALISATION CODE <script> $(document).ready(function() { $("#myTable").tablesorter({ headers: { 0: { sorter: false }, 7: { sorter: false } } }); }); </script> THE LISTING AND FORM (memberlist.php) <table id="myTable" class="tablesorter"> <thead> <tr> <th></th> <th>ID</th> <th>USERNAME</th> <th>FIRST NAME</th> <th>LAST NAME</th> <th>EMAIL</th> <th>ACTIVE?</th> <th></th> </tr> </thead> <tbody> <form name="form1" method="post" action="membermultiupdate.php"> <?php while ($rowmembers = mysql_fetch_assoc($members)) {echo ' <tr> <td><input name="membid[]" type="checkbox" id="membid[]" value="'.$rowmembers['id'].'"></td> <td>'.$rowmembers['id'].'</td> <td>'.$rowmembers['username'].'</td> <td>'.$rowmembers['first_name'].'</td> <td>'.$rowmembers['last_name'].'</td> <td>'.$rowmembers['email'].'</td> '; if ($rowmembers['active'] == 1) {echo '<td> YES </td>';} else {echo ' <td>NO </td>';} echo ' <td><a href="memberedit.php?member='.$rowmembers['id'].'"><img src="http://icons.iconarchive.com/icons/custom-icon-design/office/256/edit-icon.png" width="15" height="15" /></a> <img src="http://icons.iconarchive.com/icons/custom-icon-design/office/256/delete-icon.png" width="15" height="15" /></td> </tr>';} ?> </tbody> </table> <table><tr> <td colspan="4" align="center"><input type="submit" name="submit" value="Update Selected"></td> </tr> </form></table> THE RECEIVING SCRIPT (membermultiupdate.php) if (isset ($_POST['submit'])) { if (is_array ($_POST['membid'])) { $updateIDs = implode(', ', array_filter(array_map('intval', $_POST['membid']))); $query = "SELECT * FROM users WHERE id IN ({$updateIDs})"; $members = mysql_query($query); $count=mysql_num_rows($members); } } Any advice or pointers would be greatfully received! Thanks in advance Steve Quote Link to comment Share on other sites More sharing options...
JoeG1484 Posted August 23, 2012 Share Posted August 23, 2012 This topic looks a little dated, but I am running into the same issue... If I don't sort my table, then multiple check boxes for edit work fine... However, once I sort, then the array is not passed... Here are some relevant bits: This is the called script - it basically goes back after the post var is found to be empty... $multi_edit_address = $_POST['edit']; if(empty($multi_edit_address)) { ?> <script type="text/javascript"> window.history.go(-1); </script> Here is the calling part: echo "<th><input type=\"submit\" name=\"edit_delete\" value=\"Edit\" onclick=\"this.form.action='multi_edit.php';\" /></th>"; And from same script form... echo '<td><a href="edit.php?address=' . $row['address'] .'&RowName=' . $row_select .'">Edit</a> <input type="checkbox" name="edit[]" value="' . $row['address'] . '"/></td>'; Any assitance would be great. Let me know if you need more information. Thanks! Joe Quote Link to comment Share on other sites More sharing options...
JoeG1484 Posted August 23, 2012 Share Posted August 23, 2012 Actually, never mind! I ended up using PHP code to do my sorting... Now it even does the even/odd colors correctly - renders the page AFTER the sql query is done. Much nicer, faster, and pain free Thanks! Joe Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.