今天用到php查询数据库,代码类似于下:
$strSql="select * from mydb";
$result=mysql_query($strSql);
$tests = array();
while($row=mysql_fetch_array($result)) {
$strSql = "select count(*) from mydb2 where id=".$row['id'];
$result=mysql_query($strSql);
$row1=mysql_fetch_array($result);
$num = $row1[0];
$tests[] = array(
'id' => $row['id'],
'num' => $num
);
}foreach($tests as $test) {
echo $test['id']."<br/>";
echo $test['num']."<br/>";
}随手写的代码。可是具体思想如上。
为什么我在数据库里面查询结果并不为1,而输出仅仅有一行。
是不是mysql_fetch_array的问题。
求高手解答。