Page 1 of 1

Help with multiple arguments

Posted: Sun Nov 10, 2002 5:18 am
by khanfahd
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>");
	&#125;
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

Posted: Sun Nov 10, 2002 7:49 am
by PaTTeR
You need to change checkbox name on every loop

Code: Select all

$count=1;
while($xyz=mysql_fetch_array($sql_select)) 
   &#123; 
      $cat_id=$xyz&#1111;"cat_id"]; 
      $cat_name=$xyz&#1111;"cat_name"]; 
      $cat_desc=$xyz&#1111;"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++;	
   &#125;

check boxes and arrays

Posted: Sun Nov 10, 2002 3:36 pm
by phpScott
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