I'm trying to run 4 identical queries with different numbers, like so:
for($i=0;$i<5;$i++)
{
$sql[$i] = "SELECT * FROM whatever";
$sql[$i.$i] = "SELECT * FROM whatever2";
$res[$i] = mysql_query($sql[$i]);
$res[$i.$i] = mysql_query($sql[$i.$i];
while ($row[$i] = mysql_fetch_array($res[$i]))
{
$val[$i] = $row[$i]['Col1'];
}
while ($row[$i.$i] = mysql_fetch_array($res[$i.$i]))
{
$val[$i.$i] = $row[$i.$i]['Col2'];
}
}
However, it doesn't work. If i include echo $val[$i.$i]
in that for
it echoes nothing.
So I guess my real question is how would I overcome this? I need to run that query 4 times, where $i=1
to $i = 4
, so I get $val1, $val2, $val3, $val4
. Why can't I declare values with $row[$i.$i]
?
PS I know I shouldn't use SQL, I was hired to fix stuff =)