Yes, I tried it. The only difference is I didn't use a form, I just put an array value right into the script:
$animals = array(cats, dogs);
So the entire script would look something like this
<?
// Connect To MySQL Server
@mysql_connect($server, $username, $password) or die("Couldn't Connect to Database");
// Select Database
@mysql_select_db($database) or die("Couldn't Select Database");
/* added array here. Try with this. If this works, then the problem
is most likely in your form or in how you are calling the array. */
$animals = array(cats, dogs);
$query = "SELECT * FROM your_table";
for ($i=0; $i < count($animals); $i++) {
if ($query == 'SELECT * FROM your_table') {
$query .= " WHERE animals='$animals[$i]'";
} else {
$query .= " OR animals='$animals[$i]'";
}
}
$result = mysql_query($query) or die(mysql_error());
// so you know how many results you are getting without actually displaying. This will help in solving any problems.
echo mysql_num_rows($result) . "<br>\n";
// this will help you see what your query looks like and also help solve any problems
echo $query;
// do what you want with the results
?>
By echoing the query and the number of rows, you should be able to quickly determine what's not working properly. Once again, be sure to change your_table to your table name in BOTH places. If you're using a variable, something like
select * from $table
It may not work properly. I think I had trouble when I used a variable for the table name. You will probably want to try changing something like that to
select * from pets (or whatever your table name is, rather than using a variable)
Let me know how it goes.
Cgraz