当我直接从我的管理员 PHP 执行此查询时,我得到了 5 个结果。
SELECT img FROM `table`.`goog` WHERE `url` LIKE '%google.com%' and `pictureID` != 'picture_50d22657a423b6.62354164';
但是,当我的代码
$sql2 = "SELECT img FROM `table`.`goog` WHERE `url` LIKE '%$url%' and `pictureID` != '$pictureID';";
// echo $sql2;
$result2=mysql_query($sql2);
$rows2 = mysql_fetch_array($result2);
mysql_close($con);
print_r(count($rows2));
echo "<br/>";
echo $sql2;
它打印出来
2
SELECT img FROM `ashkan`.`goog` WHERE `url` LIKE '%66.228.42.45%' and `pictureID` != 'picture_50d22657a423b6.62354164';
我还想指出,我在管理员的 php 中运行的查询是从我的代码返回的内容中复制的。
那么,为什么一个只返回 2 个项目,而另一个返回 5 个?
编辑
我在底部添加了以下内容
var_dump($rows2);
echo "<br/>";
echo mysql_num_rows($result2);
得到了这个
array(2) { [0]=> string(1) "b" ["img"]=> string(1) "b" }
5
我有一些东西可以手动选择一行
本质上我希望能够做到
echo $rows2[somenum]; //that some number is at random and only one at a time
但是,照原样,我只能访问第 0 项,而不是全部 5 项。