我必须得到整个专栏的长度。我正在做这样的事情:
$allThumbnailName="Select sp_thumbnailName from stitchedproduct";
if($connection === false)
{
echo "Error in connection mysql_error()";
}
$ATName = mysqli_query($connection,$allThumbnailName) or die(mysqli_error($connection));
if (!$ATName) echo "hello";
$ResultAllThumbnailName = mysqli_fetch_array($ATName);
$LengthOFarrayImages = count($ResultAllThumbnailName);
echo $LengthOFarrayImages;
代码返回长度为2但我的列中有5个元素。
答案 0 :(得分:3)
根据PHP Doc mysqli_fetch_array
从结果集中提供仅一行
while($ResultAllThumbnailName = mysqli_fetch_array($ATName))
{
$rows[] = $ResultAllThumbnailName;
}
count($rows); // will give you whole length
但如果你只想找到一个长度mysqli_num_rows就可以完成这项工作
如:
$row_cnt = mysqli_num_rows($ResultAllThumbnailName);
希望这会有所帮助
答案 1 :(得分:0)
在将所有行加载到php之前,有一个函数: http://www.php.net/manual/en/mysqli-result.num-rows.php