Dont really know how to do this... SELECT field FROM table WHERE id=1 or id=4 or id=6 ... i have the ids in a php array... now i need to know wich sintax to use in order to set up a loop to build my query string. thanks in advance
Hmm - what exactly are you trying to do? What is "list" - is that a value in another table? I should be able to help but I'm not quite sure what you're after...
You need to wrap it in a while loop... here's the basic syntax: myArray = array(1,2,3,4); while (x<5) { SELECT field FROM table WHERE id=myArray[x]; } Code (markup): Put whatever code you want to duplicate within the {} of the while loop.
mmmmm.... thats like plsql... i am not so aware of what is possible to do with mysql. does mysql allows function definitions?that could make thinks easier... i also need a way to parse the php array to a mysql array.... i guess i can build the array sql string... or is there any more efficient way?
$idArray = array('1', '2', '3'); $sql = 'SELECT field FROM table WHERE id IN (' . implode(',', $idArray) . ')'; $query = mysql_query($sql); if ( mysql_num_rows($query) > 0 ){ //retrieve the rows } PHP:
thx chemo... i already have it working... i used the implode function, i've been told by somebody outrside here. But thanks anyway for the repply preciated