gpt4 book ai didi

php - 查询没有获得所有值

转载 作者:行者123 更新时间:2023-11-30 00:47:09 25 4
gpt4 key购买 nike

请检查我的以下代码,我有 6 条记录也显示在 $count 打印中,但在数组中只得到 5 条记录..请检查我在哪里做错了

session_start();
$friendlyurl=$_SESSION['favcolor'];


include('adminv/dsn.php');
$data = mysql_query("SELECT autoid FROM propertydetails where friendlyurl='$friendlyurl'")
or die(mysql_error());
$info = mysql_fetch_array( $data );
$autoid=$info['autoid'];
echo "auto id ".$autoid."<br>";

include 'config.php';
$rows = array();
$conn = @new mysqli($server,$user,$pass,$db) or die('unable to connect');
$query = "select count(*) from images where parentid=$autoid and description<>'Not Active'";
$result = $conn->query($query);
list($count) = $result->fetch_row();
$query = "select path, description from images where parentid=$autoid and description<>'Not Active'";
$result = $conn->query($query);
$checkimageexist = $count;
echo "check count ".$checkimageexist; // count shows there are 6 records
while($row = $result->fetch_array())
$rows[] = $row;
print_r(array_values($rows)); // getting 5 record instead of 6

感谢您的帮助

最佳答案

我认为您有 5 条记录。试试这个代码:

$conn = @new mysqli($server,$user,$pass,$db) or die('unable to connect');
$query = "select count(*) as f_val from images where parentid=$autoid and description<>'Not Active'";
$result = $conn->query($query);
$count = ($result->fetch_row())["f_val"];

关于php - 查询没有获得所有值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21273579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com