Gazz1982 Posted June 9, 2008 Share Posted June 9, 2008 My php with mysql generates: Delete Name Address [] Checkbox Bob Down Town [] Checkbox Dave Down Town [] Checkbox Tim Down Town For the Checkbox: echo "<td><form class='small' name='login' method='post'"; echo "<input type='checkbox' name='Add' value='yes' /></td>"; I want to add 'yes' to my dispose column in my database, how do I update the database to the row which the checkbox is? ie If i check the box next to bob I want to add 'yes' to the dispose column only for Bob The checkboxes are generated through a loop so all will have the same name the mysql table as a unique id auto_increment primary key; Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/109469-deleting-a-row-in-a-php-table/ Share on other sites More sharing options...
Barand Posted June 9, 2008 Share Posted June 9, 2008 see http://www.phpfreaks.com/forums/index.php/topic,199859.msg903053.html#msg903053 Quote Link to comment https://forums.phpfreaks.com/topic/109469-deleting-a-row-in-a-php-table/#findComment-561526 Share on other sites More sharing options...
Gazz1982 Posted June 9, 2008 Author Share Posted June 9, 2008 ok looks like what i need echo "</table>"; echo"<br /><br />"; echo "<table border='1'> <tr> <th>Delete</th> <th>Firstname</th> <th>Lastname</th> <th>Email</th> <th>Password</th> <th>Company</th> <th>Address1</th> <th>Address2</th> <th>Address3</th> <th>County</th> <th>Country</th> <th>Post Code</th> <th>Phone Number</th> <th>Validate</th> </tr>"; while($row = mysql_fetch_array($result2)) { echo "<tr>"; echo "<td><form class='small' name='login' method='post'>'"; echo "<input type='checkbox' name='Delete' value='<?php echo $rows['id']?>' /></p></td>"; echo "<td>" . $row['NAME_FIRST'] . "</td>"; echo "<td>" . $row['NAME_LAST'] . "</td>"; echo "<td>" . $row['EMAIL'] . "</td>"; echo "<td>" . $row['PASSWORD'] . "</td>"; echo "<td>" . $row['COMPANY'] . "</td>"; echo "<td>" . $row['ADDRESS1'] . "</td>"; echo "<td>" . $row['ADDRESS2'] . "</td>"; echo "<td>" . $row['ADDRESS3'] . "</td>"; echo "<td>" . $row['COUNTY'] . "</td>"; echo "<td>" . $row['COUNTRY'] . "</td>"; echo "<td>" . $row['POST_CODE'] . "</td>"; echo "<td>" . $row['PHONE'] . "</td>"; echo "<td>" . $row['VALIDATE'] . "</td>"; echo "</tr>"; } echo "</table>"; just trying to figure out this bit - sorry I'm a bit of a novice - all help welcomed $ids = join (',', $_POST['delID']); $sql = "DELETE FROM docs WHERE docID IN ($ids)"; mysql_query($sql); Quote Link to comment https://forums.phpfreaks.com/topic/109469-deleting-a-row-in-a-php-table/#findComment-561542 Share on other sites More sharing options...
.josh Posted June 9, 2008 Share Posted June 9, 2008 $sql = "DELETE FROM docs WHERE docID IN ('$ids')"; Other than that...what are you trying to figure out? Quote Link to comment https://forums.phpfreaks.com/topic/109469-deleting-a-row-in-a-php-table/#findComment-561546 Share on other sites More sharing options...
Barand Posted June 9, 2008 Share Posted June 9, 2008 if you ran this $ids = join (',', $_POST['delID']); $sql = "DELETE FROM docs WHERE docID IN ($ids)"; echo $sql; you would see something like DELETE FROM docs WHERE docID IN (1,5,8,9) which would delete the 4 rows with those ids Quote Link to comment https://forums.phpfreaks.com/topic/109469-deleting-a-row-in-a-php-table/#findComment-561552 Share on other sites More sharing options...
.josh Posted June 9, 2008 Share Posted June 9, 2008 sorry I read the join wrong idk why but I thought I saw it as "','" Quote Link to comment https://forums.phpfreaks.com/topic/109469-deleting-a-row-in-a-php-table/#findComment-561553 Share on other sites More sharing options...
Gazz1982 Posted June 9, 2008 Author Share Posted June 9, 2008 ok so now im getting delete name ID [] Bob 1 [] Dave 2 [] Time 3 when the table is created where ID is $del which = $row['ID'] The value in the check box is also $del [] = checkbox so now if I run select * from login where ID = $del it should select all of the ones which were checked ??? Am I right or close? Quote Link to comment https://forums.phpfreaks.com/topic/109469-deleting-a-row-in-a-php-table/#findComment-561574 Share on other sites More sharing options...
Barand Posted June 9, 2008 Share Posted June 9, 2008 your form code should be <?php echo "<form class='small' name='login' method='post'>'"; // Only ONE form echo "<table border='1'> <tr> <th>Delete</th> <th>Firstname</th> <th>Lastname</th> <th>Email</th> <th>Password</th> <th>Company</th> <th>Address1</th> <th>Address2</th> <th>Address3</th> <th>County</th> <th>Country</th> <th>Post Code</th> <th>Phone Number</th> <th>Validate</th> </tr>"; while($row = mysql_fetch_array($result2)) { echo "<tr>"; echo "<input type='checkbox' name='Delete[]' value='{$row['id']}' /></p></td>"; // NOTE the [] echo "<td>" . $row['NAME_FIRST'] . "</td>"; echo "<td>" . $row['NAME_LAST'] . "</td>"; echo "<td>" . $row['EMAIL'] . "</td>"; echo "<td>" . $row['PASSWORD'] . "</td>"; echo "<td>" . $row['COMPANY'] . "</td>"; echo "<td>" . $row['ADDRESS1'] . "</td>"; echo "<td>" . $row['ADDRESS2'] . "</td>"; echo "<td>" . $row['ADDRESS3'] . "</td>"; echo "<td>" . $row['COUNTY'] . "</td>"; echo "<td>" . $row['COUNTRY'] . "</td>"; echo "<td>" . $row['POST_CODE'] . "</td>"; echo "<td>" . $row['PHONE'] . "</td>"; echo "<td>" . $row['VALIDATE'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "</form>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/109469-deleting-a-row-in-a-php-table/#findComment-561594 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.