Posted by giloosh on 08/29/07 16:02
i would like to filter out a bunch rows from a table of sql row
results.
i have a checkbox on each row named checkbox[x]
(x = the current row id)
i will submit the form and take all the rows that are checked and
filter out the ones that are not checked.
so if i had 10 rows and i checked 3 of them then when i submit the
form only those 3 rows will show up.
I was wondering what was the best way to call those rows in the sql
statement.
Would i just loop through the rows that were checked and add them to
the WHERE STATEMENT using the OR condition?
select * from rows where id = 3 or id = 2 or id = 6 or id = 10
so basically i would do something like this with the php code.
$sql = "select * from rows WHERE 1 ";
foreach ($_POST[checkbox] as $check){
$sql .= " OR id = $check";
}
I just think its slow to use so many OR conditions in one sql
statement, but i cant think of anyway else to do this.
Is the way i want to do this a good way?
Thanks for your help
[Back to original message]
|