【发布时间】:2012-08-21 00:25:06
【问题描述】:
我有以下获取单行的代码:
$query = "SELECT *
FROM translations
WHERE iddoc = '$id'
AND submitted = 1;";
$result = mysqli_query($query);
$row = mysqli_fetch_array($result);
我知道这在 while 循环中很有用,您可以在其中循环遍历结果。
但我需要能够抓取满足此条件的特定行。这个伪代码后面的东西:
$query = "SELECT *
FROM translations
WHERE iddoc = '$id'
AND submitted = 1;";
$result = mysqli_query($query);
$arrayofrows = mysqli_fetch_arrayofrows($result);
$arrayofrows[0] //(to get the first row)
$arrayofrows[1] //(2nd row)
等等……
我该怎么做?
【问题讨论】:
-
为什么不在 Where 子句中加入额外的条件?
-
这是最好的(唯一)方法吗?我无法返回包含所有结果的数组?