> I'm displaying the content of a mysql table with autoincrement index.
I
> want to be able to select the each row from the table using the check
> boxes. In order to do that, i want to assign to each checkbox the
> name=index of selected row.
> I assign to the checkboxes the value of selected id, but I can't
> retreiveit later for further processing. My code looks like this
> 
>  $query = "SELECT * FROM reclamatie";
>     $result = mysql_query($query) or die("Query failed");
> 
>     /* Printing results in HTML */
> 
>  echo "<table border=1>";
>     echo
>
"<tr><td></td><td>ID</td><td>Subject</td><td>Open</td><td>Close</td></tr
>"
> ;
> 
>      while($row = MySQL_fetch_array($result)) {
>          echo  "<tr><td><form><input type=\"checkbox\" method=\"post\"
> name=\"{$row['id']}\"></form></td>"; // ??????????

It looks like your naming it as a number, which won't work for PHP. You
want to name all of your checkboxes the same, with a [] on the name to
make the results an array in PHP.

... name="id[]" value="{$row['id']}"

Then, you'll have $_POST['id'][x] as an array in PHP. Only the
checkboxes that were selected will be in the array, from zero to however
many were checked. The value of $_POST['id'][x] will be whatever was in
the value="..." part of the HTML checkbox...

---John Holmes...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to