Hi
I'm not sure i'm going about this the right way, but I'll try and explain it anyway. Basically, i'm trying to populate an array from an sql query using an array. For example:
Lets say i have an array array("dog","cat","mouse")
Using that array i want to query a database to select * where the contents of the array match. I'm guessing you can do this with a foreach statement, but for now i've done it like this:
$animals = array("dog","cat","mouse");
//i've counted the contents of the array
//as it can have more than three values
$vals = count($animals);
$sql = array();
for($n=0; $n<$vals; $n++)
{
$query = $animals[$n];
$sql[$n] = mysql_fetch_array(mysql_query("SELECT * from farmyard WHERE animal_name='$query'"));
}
now if i printed the contents of the array i only get the first result where a match was found and not the remaining times, i.e. pretend the db contains information about 3 dogs, 2 cats and 5 mice. I'd only get the output (using var_dump()) of the first dog.
Any ideas?
Thanks for taking time to read this, sorry if i haven't been very clear. I just want to popultae the sql array with all the contents from the SQL statement for each animal
Cheers
Ant