Okay what I am trying to do might be hard to understand, but I will give it my best shot. I have created a script which selects data randomly from a table called albumname in a databse called characters. This array is then used again in a mysql_query to select the table from a different database named photos. It does this correctly. The problem occurs when I try to put the results from the mysql_query into a new array. It will only put the first result into the array and forget the rest. Here is the script,
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("characters", $con);
$query="SELECT album FROM albumname ORDER BY RAND() LIMIT 9";
$result= mysql_query($query) or die(mysql_error());
$i=0;
while($row = mysql_fetch_array($result)){
$images[$i] = $row[0];
$i++;
}
?>
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("photos", $con);
//The problem occurs here.
$q = 0;
$query2="SELECT Location FROM $images[$q] WHERE Pic_id='1'";
$data= mysql_query($query2) or die(mysql_error());
while( $info = mysql_fetch_array( $data ) && $q < 9){
$query2="SELECT Location FROM $images[$q] WHERE Pic_id='1'";
$data= mysql_query($query2) or die(mysql_error());
$info2[$q] = $info[0];
$q++;
}
mysql_close($con);
?>