Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.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 搜索结果显示_Php_Mysqli - Fatal编程技术网

Php 搜索结果显示

Php 搜索结果显示,php,mysqli,Php,Mysqli,我有一个网站项目,客户将需要搜索,结果将显示,所以我已经做了所有这些,但问题是当搜索结果出现时,如果有超过1行,它会在同一行上复制结果,下面是代码 <h1 style="font-family:calibri;color:#13CC0D;text-align:center;">BODABODA SEARCH RESULTS</h1> <table cellpadding="1" cellspacing="1" id="resultTable">

我有一个网站项目,客户将需要搜索,结果将显示,所以我已经做了所有这些,但问题是当搜索结果出现时,如果有超过1行,它会在同一行上复制结果,下面是代码

 <h1 style="font-family:calibri;color:#13CC0D;text-align:center;">BODABODA SEARCH RESULTS</h1>
<table cellpadding="1" cellspacing="1" id="resultTable">
                        <thead>
                            <tr>
                                <th style="border-left: 1px solid #C1DAD7"> Region</th>
                                <th> District </th>
                                <th> Ward </th>
                                <th> Street</th>
                                <th> Driver Name </th>
                                <th>Identification Type</th>
                                <th>Identification Number</th>
                                <th>Motorcycle Type</th>
                                <th>Motorcycle Reg No</th>
                                <th>Phone Number</th>
                            </tr>
                        </thead>

<?php
  $conn = mysqli_connect('localhost', 'efalococ_calcia', '*ad4@zNQ=nfN') or die('can not connect to the server'.mysqli_error);
 mysqli_select_db($conn, 'efalococ_safirii');
  if(isset($_POST['search'])){
      $query  =  $_POST['region'];
      $query1 =  $_POST['district'];
      $query2 =  $_POST['ward'];
      $query3 =  $_POST['street'];

      $results = mysqli_query($conn,"SELECT * FROM bodaboda WHERE (`region` LIKE '%".$query."%') && (`district` LIKE '%".$query1."%') && (`ward` LIKE '%".$query2."%') && (`street` LIKE '%".$query3."%')") or die(mysql_error());
      if(mysqli_num_rows($results) >0){
          while($row = mysqli_fetch_array($results)){
         echo "<td>".$row['Region']."</td>" ;
         echo "<td>".$row['District']."</td>";
         echo "<td>".$row['Ward']."</td>";
         echo "<td>".$row['Street']."</td>";
         echo "<td>".$row['DriverName']."</td>";
         echo "<td>".$row['IdentificationType']."</td>";
         echo "<td>".$row['IdentificationNumber']."</td>";
         echo "<td>".$row['MotorcycleType']."</td>";
         echo "<td>".$row['MotorcycleRegNo']."</td>";
         echo "<td>".$row['PhoneNumber']."</td>";
          }
      }else{
          echo '<span style="color:red;font-family:cursive;font-size:14px;">No results found, Please Modify your search&nbsp;</span> <a href="search_bodaboda.php" style="font-family:cursive;text-decoration:none;font-size:14px;">Click here</a>'.mysqli_error($conn);
      }
  }
?>
 </table>
BODABODA搜索结果
区域
地区
病房
街头
驱动程序名称
识别类型
识别号
摩托车类型
摩托车注册号
电话号码

您只需要对每一行使用

标记定义HTML表中的一行

了解更多关于

while($row=mysqli\u fetch\u数组($results)){
回声“;
回显“$行[“区域]”;
回显“$行[“地区]”;
回显“$row['Ward]”;
回音“$行[“街道]”;
回显“$row['DriverName]”;
回显“$row['IdentificationType']”;
回显“$row['IdentificationNumber']”;
回显“$row['motorketype]”;
回显“$row['motorkeregno']”;
回显“$row['PhoneNumber']”;
回声“;
}

打开和关闭循环中的行~记录不同,但您需要
tr
tagsRamRaider,非常感谢这一修复。
mysql\u error()
函数不再存在。非常感谢,我也能够复制它。@caliamasaki很棒。。。快乐编码!顺便说一句,别忘了接受答案。
 while($row = mysqli_fetch_array($results)) {
     echo "<tr>";
     echo "<td>".$row['Region']."</td>" ;
     echo "<td>".$row['District']."</td>";
     echo "<td>".$row['Ward']."</td>";
     echo "<td>".$row['Street']."</td>";
     echo "<td>".$row['DriverName']."</td>";
     echo "<td>".$row['IdentificationType']."</td>";
     echo "<td>".$row['IdentificationNumber']."</td>";
     echo "<td>".$row['MotorcycleType']."</td>";
     echo "<td>".$row['MotorcycleRegNo']."</td>";
     echo "<td>".$row['PhoneNumber']."</td>";
     echo "</tr>";
 }