I think its just late and my shrivelling brain just can't handle anymore code, but, i have a problem.
I have a page that is bringing back all the rows in a given database, i have a checkbox for each row brought back that has the value of the auto incremented id (cid in my case). Now i have a delete button, and the idea is check which rows i want to delete from the database then when i press delete, hey presto there gone.
My question is, when i click the submit button, how can i tell which checkboxes have been ticked, so i can pass these 'cid's' to the next page, or just process them on the same page in a statement.
Please see the part of my code that deals with this (form code)
include'../connect.php';
$tbl_name="comments";
mysql_connect("$host", "$username", "$password")or die("cannot connect to the DB");
mysql_select_db("$db_name")or die("cannot select DB");
$sql = "select * from $tbl_name order by cid asc";
$results = mysql_query($sql);
echo"<form id='ccform' method='post' action=''>";
while($row = mysql_fetch_array($results)){
echo"<div id='commentcheck'>";
echo"<font color='white'>Name:</font> ".$row['name']." <br/>";
echo"<font color='white'>IP Addr:</font> ".$row['ip']." <br/>";
echo"<font color='white'>Timestamp:</font> ".$row['timestamp']."<br/>";
echo"<font color='white'>Comment:</font> ".$row['comment']." <br/>";
echo"<input type='checkbox' name='posts' value='".$row['cid']."'> Delete";
echo"</div><br/><br/>";
}
echo"<input name='del' type='submit' value='Delete checked posts' height='10px' />";
echo"</form>";
Please let me know if you require further explanation, or just have a question.
Many Thanks in advance.
Chopster

New Topic/Question
Reply



MultiQuote





|