legohead6 Posted May 20, 2006 Share Posted May 20, 2006 Hi, This is a private message inbox from a forum...i want so that when you check the box on a message it deletes it!Heres the code:[code]<?PHPsession_start();echo "<p align=center><font size=6>Inbox</font></p>";echo "<p align=center><a href='sendpm.php'>Send a Message</a><br><br></p>";$username="*********";$password="*********";$database="*********";$user=$_SESSION['user'];mysql_connect(localhost,$username,$password);@mysql_select_db($database) or die( "Unable to select database");$query2 = "SELECT * FROM Pmess Where tname='$user'";$result2 = mysql_query($query2) or die ("Error in query: $query2. ".mysql_error());echo "<form method='POST'>";$t=0;while($row = mysql_fetch_row($result2)){echo "<table cellpadding='0' cellspacing='0' width='373' border=1><tr><td><b>By:</b> $row[2]<br><br> <b>Subject:</b> $row[3]<br><br><b>Message:</b><br> $row[4]<br><br>Delete:<input type='checkbox' name='$row[0]' value='$row[0]'></td></tr></table><br>";$t++;}echo "<input type='submit' name='sub' value='Delete'></form>";if(isset($_POST['sub'])){//Need something!//?></html>[/code] Link to comment https://forums.phpfreaks.com/topic/10052-deleting-variable-number-of-checkboxes/ Share on other sites More sharing options...
448191 Posted May 20, 2006 Share Posted May 20, 2006 Have your checkboxes load the values (id's) into an array.Example:[b]<input type='checkbox' name='delete[]' value='$row[0]'/>[/b]$_POST['delete'] will now contain an array populated with the id's of messages to be deleted.I take it you know what to do from here. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Link to comment https://forums.phpfreaks.com/topic/10052-deleting-variable-number-of-checkboxes/#findComment-37397 Share on other sites More sharing options...
legohead6 Posted May 20, 2006 Author Share Posted May 20, 2006 thanks i new i have to use an array! i just could figure out how.....ok..i will try that! Link to comment https://forums.phpfreaks.com/topic/10052-deleting-variable-number-of-checkboxes/#findComment-37431 Share on other sites More sharing options...
448191 Posted May 20, 2006 Share Posted May 20, 2006 Glad to be of service. Link to comment https://forums.phpfreaks.com/topic/10052-deleting-variable-number-of-checkboxes/#findComment-37448 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.