比较来自世界各地的卖家的域名和 IT 服务价格

PHP :警告: mysqli_num_rows// 期待参数 1 将会 mysqli_result, 指定字符串

我正在尝试按照以下要求获取数据


$query= "SELECT * FROM residential "; 
if/$type!=""/{
$query.=" AND type='$type'";
}
if/$unit_type!=""/{
$query.=" AND unit_type='$unit_type'";
}
if//$min_price!=""/ && /$max_price!=""//{
$query.=" AND price BETWEEN '$min_price' AND '$max_price' ";
}
if//$min_bedrooms!=""/ && /$max_bedrooms!=""//{
$query.=" AND bedrooms BETWEEN '$min_bedrooms' AND '$max_bedrooms'";
}
if/$query==FALSE/{
echo mysqli_error/$connect/;
die;
}
$result= mysqli_query/$connect,$query/;


这就是我使用它的方式


<div class="row">
<?php if/mysqli_num_rows/$query/>0/:?&gt;
<?php while/$row= mysqli_fetch_assoc/$query//:
print_r/$row/;
die;
?>
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="row property-listing">
<div class="col-md-6 col-sm-6 col-xs-12">
<img class="img-responsive full-width" src="images/1.png"/>
</div>
<div class="col-md-6 col-sm-6 col-xs-12 property-desc">
<h3>AED<br/> <?php echo $row['price'];?></h3>
<h5>Unit Type: <?php echo $row['unit_type'];?></h5>
<h5>Available for :<?php echo $row['type'];?></h5>
<h5>Location :<?php echo $row['area'];?></h5>
<h5>Bedrooms :<?php echo $row['bedrooms'];?></h5>
</div>
</div>
</div>
<?php endwhile;?>
<?php else:
echo 'We found no record for your search criteria ';
echo '<a href="index.html">Refine Search'
?&gt;

<?php endif;?>
</div>


这就是我的错误

/ ! / 警告: mysqli_num_rows// 期待参数 1 将会
mysqli_result, 指定字符串

价值 , 发布和删除,是正确的,但请求有问题,请帮助我弄清楚

谢谢
已邀请:

八刀丁二

赞同来自:

$query

- 这是一个查询字符串,而不是生成的集合。 所以只是使用
$result



php if/mysqli_num_rows/$result/0/:?>
php while/$row= mysqli_fetch_assoc/$result//:


</div
<div class="answer_text">
只需更改此代码


$query= "SELECT * FROM residential ";





$query= "SELECT * FROM residential WHERE 1";


并更改此代码


<?php if/mysqli_num_rows/$query/>0/:?&gt;
<?php while/$row= mysqli_fetch_assoc/$query//:
print_r/$row/;
die;
?>





<?php 
$res = mysqli_query/$con, $query/; //replace $con with your db connection variable
if/mysqli_num_rows/$res/>0/:?&gt;
<?php while/$row= mysqli_fetch_assoc/$res//:
print_r/$row/;
die;
?>


</div>
<div class="answer_text">
你加到k。
mysqli_num_rows//


mysqli_fetch_assoc//

当她期待时查询字符串
mysqli_result

- 在您的情况下,它是一个变量
$result

.
</div>
<div class="answer_text">
询问 Sql 您不包括优惠 WHERE.

如果要将请求合并为第一个请求的另一个参数 sql, 添加

句子 WHERE 在你的第一行 sql 通过以下方式


$query= "SELECT * FROM residential WHERE table_id!=0";

这里

table_id

是你的主要键

桌子

.it 结合请求将是一个很好的做法。
之后,例如,可以添加其他值以组合查询,例如


if/$type!=""/{
$query.=" AND type='$type'";
}


所以你的最新要求看起来像这样


SELECT * FROM residential WHERE table_id!=0 AND type='$type'


接下来你通过
$query



mysqli_num_rows

你必须通过
$result

为了这
</div>

三叔

赞同来自:

只需更改此代码


$query= "SELECT * FROM residential ";





$query= "SELECT * FROM residential WHERE 1";


并更改此代码


php if/mysqli_num_rows/$query/0/:?>
php while/$row= mysqli_fetch_assoc/$query//:
print_r/$row/;
die;
?





php 
$res = mysqli_query/$con, $query/; //replace $con with your db connection variable
if/mysqli_num_rows/$res/0/:?>
php while/$row= mysqli_fetch_assoc/$res//:
print_r/$row/;
die;
?

窦买办

赞同来自:

你加到k。
mysqli_num_rows//


mysqli_fetch_assoc//

当她期待时查询字符串
mysqli_result

- 在您的情况下,它是一个变量
$result

.

郭文康

赞同来自:

询问 Sql 您不包括优惠 WHERE.

如果要将请求合并为第一个请求的另一个参数 sql, 添加

句子 WHERE 在你的第一行 sql 通过以下方式


$query= "SELECT * FROM residential WHERE table_id!=0";

这里

table_id

是你的主要键

桌子

.it 结合请求将是一个很好的做法。
之后,例如,可以添加其他值以组合查询,例如


if/$type!=""/{
$query.=" AND type='$type'";
}


所以你的最新要求看起来像这样


SELECT * FROM residential WHERE table_id!=0 AND type='$type'


接下来你通过
$query



mysqli_num_rows

你必须通过
$result

为了这

要回复问题请先登录注册