You are here: return multiple rows from sql statement « PHP Programming Language « IT news, forums, messages
return multiple rows from sql statement

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация