0

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 =)

4

1 回答 1

3

那是错误的。为什么不使用 $sql1[$i] 和 $sql2[$i] ?如果你去 11 $i.$i when i = 1 和 $i when i = 11 会发生碰撞。

于 2013-11-06T18:16:05.563 回答