Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 检查mysqli_查询是否为空_Php_Mysql - Fatal编程技术网

Php 检查mysqli_查询是否为空

Php 检查mysqli_查询是否为空,php,mysql,Php,Mysql,我正在寻找一种方法来检查我的mysqli_查询结果是否为空 我的代码: $result = mysqli_query($con, "SELECT ......"); 然后是桌头: <table class="table table-striped" width="100%"> <thead> <table class="table table-striped" width="100%"> <thead> &

我正在寻找一种方法来检查我的mysqli_查询结果是否为空

我的代码:

$result = mysqli_query($con, "SELECT ......");
然后是桌头:

<table class="table table-striped" width="100%">
<thead>
<table class="table table-striped" width="100%">
        <thead>
            <th>Jahr</th>

加尔
然后我用while循环生成行:

while($ausgabe = mysqli_fetch_object($result)){ ?>
        <tr>
            <td><?php echo $ausgabe->jahr; ?></td>
while($ausgabe=mysqli\u fetch\u object($result)){>
现在我想做一个if查询,检查我是否必须在表开始之前显示表,如下所示:

if($result){    
<table class="table table-striped" width="100%">
        <thead>
            <th>Jahr</th>
如果($result){
加尔
但这不起作用,它只适用于询问mysqli_fetch_对象是否为空,但此代码位于我的表头下方,因此我无法使用此代码

你有什么想法吗?

你可以使用

你可以使用


如果您需要了解可用的内容,请查看手册。手册对我来说有多少是无用的,我已经检查过了,否则我不会写这个!如果我在mysqli\u fetch\u对象前面使用num\u行,那么mysqli\u fetch\u对象在…之后是空的,唯一让它对我有效的方法是进行两个mysqli\u查询,但这似乎效率低下r me.如果你想知道什么是可用的,请看手册。手册对我来说有多少是无用的,我已经检查过了,否则我就不会写这个了!如果我在mysqli\u fetch\u对象前面使用num\u行,那么mysqli\u fetch\u对象在…之后是空的,唯一让它对我有效的方法是进行两次mysqli\u查询,但这似乎效率低下nt对我来说。这对我不起作用,我用if(mysqli_num_rows($result)==0)尝试了它{但它总是空的。如果我删除num_rows,我会再次输出…这对我不起作用,我用if(mysqli_num_rows($result)==0)尝试了它{但它总是空的。如果我删除num rows,我会再次输出。。。
$results = $mysqli->query("SELECT * FROM table");
if($results->num_rows === 0)
{
   echo 'No results';
 }
else
{
//HERE YOU PROCESS 
while(){....}
}