Page 2 of 2

Re: tickbox loop

Posted: Thu Aug 21, 2003 2:34 pm
by m3rajk
i'm not even going to bother reading all of this because i don't need it to give you what you neeed. however what YOU need to do, is have a way to id each message that's constant BETWEEN users.

exampli gratia:

you're using mysql and the table for messages has this format:
message_id_number bigint unsigned auto_increment NOT NULL PRIMARY KEY,
member_id_number int unsigned NOT NULL PRIMARY KEY,
message_text text NOT NULL,


now for this example you just have to have the value of the checkbox be equal to the message id. then when they check it off you send to the db

DELETE * FROM messages WHERE message_id_number='message_id_number'
irealms wrote:I am writing an on-site message system and i have a tickbox next to each message to delete them. How do i track each message so that if you tick say the first and third message it will know that the user ticked them so i can run a delete query on each?

Code: Select all

<?php

echo '<p class="main">e-post inbox for '.$_SESSION['valid_user'].'.</p>';
echo '<table class="main" cellspacing="5" cellpadding="5" border="0">';
echo '<form method="post" action="index.php?page=e-post">';
echo '<tr><td><input type="checkbox" name="deleteall"></td><td></td><td><b>From</b></td><td><b>Date sent:</b></td><td><b>Time sent:</b></td><td><b>Subject</b></td></tr>';
$showmail = "SELECT * FROM e_post WHERE username='$_SESSION[valid_user]' AND groupname='$_SESSION[groupname]'";
$showresult = mysql_query($showmail, $db_conn) or die("Query showmail failed".mysql_error());
while ($showrow = mysql_fetch_assoc($showresult))
{
	echo '<tr>';
	echo '<td><input type="checkbox" name="delete[]"></td>';
	echo '<td></td>';
	echo '<td>'.$showrow['from'].'</td>';
    echo '<td>'.$showrow['sentdate'].'</td>';
	echo '<td>'.$showrow['senttime'].'</td>';
	echo '<td>'.$showrow['subject'].'</td>';
	echo '</tr>';
}
echo '</table>';
echo '</form>';

?>