我有 2 个查询。我正在应用第一个选择查询,并使用 my_fetch_array 通过 while 循环获取结果,但是,在那段时间内,我正在使用另一个选择查询,但此时我遇到了错误。
我不能在 while 内使用另一个选择吗?
$i = 1;
$result1 = mysql_query("SELECT x, count(*) FROM table1 group by x ORDER BY count(*) desc");
while ($rowRes1= mysql_fetch_array($result1 ))
{
echo "<tr>";
echo "<td ALIGN=CENTER style=width:5%>" . $i . "</td>";
echo "<td ALIGN=CENTER style=width:40%>" . $rowRes1['0'] . "</td>";
echo "<td ALIGN=CENTER style=width:10%>" . $rowRes1['1'] . "</td>";
$result2 = mysql_query("SELECT x FROM data where x = $rowRes1['0'] ORDER BY y ASC LIMIT 1")
while ($rowRes2= mysql_fetch_array($result2 ))
{
echo "<td ALIGN=CENTER style=width:10%>" . $rowRes2['0'] . "</td>";
}
$i++;
}