Jump to content


Photo

deleting variable number of checkboxes


  • Please log in to reply
3 replies to this topic

#1 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 20 May 2006 - 06:56 AM

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:

<?PHP
session_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>

"Syntax error" .. WHERE THE **** IS IT?!

#2 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 20 May 2006 - 09:07 AM

Have your checkboxes load the values (id's) into an array.

Example:
<input type='checkbox' name='delete[]' value='$row[0]'/>

$_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\" /]

#3 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 20 May 2006 - 03:00 PM

thanks i new i have to use an array! i just could figure out how.....ok..i will try that!
"Syntax error" .. WHERE THE **** IS IT?!

#4 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 20 May 2006 - 04:18 PM

Glad to be of service.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users