checkbox by items in list from database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
deezin
Forum Newbie
Posts: 9
Joined: Sat May 11, 2002 3:21 pm

checkbox by items in list from database

Post 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.
User avatar
enygma
Site Admin
Posts: 175
Joined: Fri Apr 19, 2002 8:29 am
Location: Dallas, Tx

Post 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)
Post Reply