You are here: Re: [PHP] Array Select from database « PHP « IT news, forums, messages
Re: [PHP] Array Select from database

Posted by Robin Vickery on 09/28/05 15:55

On 9/28/05, Frank Keessen <fkeessen@gmail.com> wrote:
> O.K. Again;
> I have an array with one or more values, which must be selected in the
> database
> Array ( [count] => 1 [0] => Array ( [clientaccountmanager] => Array (
> [count] => 2 [0] => 210 [1] => 149 )
> Now i this is my select..
> I've got the following Query="select * from client WHERE
> clientaccountmanager='$value of array1' OR '$2nd value of array 1'"
>
> How can i loop through the query with all the values out of the array as OR
> value..

Are you trying to generate the query from the array?

If so, you are better off using the SQL 'IN' construct.

SELECT * FROM client WHERE clientaccountmanager IN (value1, value2, value3,...)

Then all you need to do is generate a comma separated list of values
from the array, which you can easily do with join().

$values = join(', ', $array);

Then insert it in your query:

$query = "SELECT * FROM client WHERE clientaccountmanager IN ($values)"

-robin

 

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

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