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
khanfahd
Forum Newbie
Posts: 1 Joined: Sun Nov 10, 2002 5:18 am
Post
by khanfahd » Sun Nov 10, 2002 5:18 am
i made a dynamic form which creates a table on runtime, and in front of every record shows a checkbox.
following is code:
Code: Select all
while($xyz=mysql_fetch_array($sql_select))
{
$cat_id=$xyzї"cat_id"];
$cat_name=$xyzї"cat_name"];
$cat_desc=$xyzї"cat_desc"];
print("<tr>");
print("<td><input type=checkbox name=c1 value=$cat_id></td>");
print("<td>$cat_id</td>");
print("<td>$cat_name</td>");
print("<td>$cat_desc</td>");
print("</tr>");
}
the problem with this is that, when i select multiple checkboxes, it still sends only a single value.
Can someone please help me with this
PaTTeR
Forum Commoner
Posts: 56 Joined: Wed Jul 10, 2002 7:39 am
Location: Bulgaria
Contact:
Post
by PaTTeR » Sun Nov 10, 2002 7:49 am
You need to change checkbox name on every loop
Code: Select all
$count=1;
while($xyz=mysql_fetch_array($sql_select))
{
$cat_id=$xyzї"cat_id"];
$cat_name=$xyzї"cat_name"];
$cat_desc=$xyzї"cat_desc"];
print("<tr>");
print("<td><input type=checkbox name=c$count value=$cat_id></td>");
print("<td>$cat_id</td>");
print("<td>$cat_name</td>");
print("<td>$cat_desc</td>");
print("</tr>");
$count++;
}
phpScott
DevNet Resident
Posts: 1206 Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.
Post
by phpScott » Sun Nov 10, 2002 3:36 pm
If you want to keep track of whick checkboxes people of selected in that group then name them like so:
<input type="checkbox" name="cb[]" value="first selection">
<input type="checkbox" name="cb[]" value="another selection">
will create and array called cb[] that you can now run through and see what values have been passed along with each selection.
save all that seperate name stuff and having to deal with too many variable names.
phpScott