Page 1 of 1

checkbox by items in list from database

Posted: Sun Jul 14, 2002 10:07 pm
by deezin
Hi. I would appreciate it if you could help. I have read about 10 php books and I have never seen any of the books explain how to do this. I want to list items from a database and put a checkbox by each item. Users should be able to check multiple items in the list by clicking on the checkboxes. After the person clicks on all of the checkboxes that he wants, I will want to then add or delete all of these items or assign a value to a field in the database that is associated with the items in the list that are checked.


echo "<tr>";
while(list($groups, $username, $f_name, $l_name) = mysql_fetch_row($result2))
{
print ("<tr><td bgcolor=\"$row_bgcolor\"><li><a href=admin_userinfo.php?username=$username>$f_name $l_name</a></td>");
print("<td bgcolor=\"white\"><b>$groups</b></td></tr>");
}
echo "</tr>";

Thank you so much for your help.

Posted: Mon Jul 15, 2002 8:53 am
by enygma
just use a fetch and then name the checkboxes like an array....for example:

<?php
while($rows=mysql_fetch_assoc($result2)){
echo "<input type=\"checkbox\" name=values[] value=\"".$groups."\">$groups\n";
}
?>

or something similar....then, when it posts, all the selected checkbox values will be in that array ($values)