RE: Passing marked rows in a table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Assuming you have an artificial key for your table (like an auto increment
column), I would place the key field to the table on your form in the value
of the checkbox;

<input type=checkbox name="recsel[]" value="$rowid">

When the form is returned to your "post" php script it will only receive
those checkboxes that are checked and they will come loaded in an array
(because of the way the name is described, containing the [] characters);

$selarray = $_POST["recsel"];

If(is_array($selarray)) $query = "select * from datatable where tblkey in
(".implode(", ",$selarray).") ";
Else echo "nothing selected";  // even an array containing one occurrence is
sufficient.

I believe all this is correct.  Good luck,

Warren Vail


-----Original Message-----
From: Todd Cary [mailto:todd@xxxxxxxxxxxxxxxxxx] 
Sent: Tuesday, November 02, 2004 1:38 PM
To: php-general@xxxxxxxxxxxxx
Subject:  Passing marked rows in a table


I create a list of records from a DB and each has a check box.  What is 
the best way to select those that were checked after the form is submitted?

Todd

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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux