小编anu*_*upr的帖子

while循环只打印表中的一行,其他行未在表中打印

这里的问题是表中没有打印所有值.我从数据库中收到所有信息,表格中只打印了一行,下面打印了其他值.因为,当我搜索名称"Alex"时,我在db中有更多具有相同名称的值,我得到了所有这些值,但表中只打印了一个值.

<div id="search">
    <form method="get" action="search_display.php"  id="searchform">
    <h1> Search </h1>
    <input type="text" name="query" />
    <input type="submit" value="Traži" /> 
</div>

//search_display.php   file
<?php
     $query = $_GET['query'];
     $min_length = 3;
     if(strlen($query) >= $min_length){

         $sql_result = mysql_query("SELECT * 
                                    FROM clanovi 
                                    WHERE (`IME` LIKE '$query') 
                                    OR (`PREZIME` LIKE '$query ') 
                                    OR (`FIRMA` LIKE '$query')")  or die(mysql_error());

         if(mysql_num_rows($sql_result) > 0){
            echo "<table border='5'>
            <tr>
              <th>IME</th>
              <th>PREZIME</th>
              <th>FIRMA</th>
              <th>ADRESA</th>
              <th>TELEFON</th>
              <th>FAX</th>
              <th>MOBITEL</th>
              <th>EMAIL </th>
              <th>WEB_STRANICA </th>
              <th>GRAD </th>
              <th>KATEGORIJA </th>
              <th>PROIZVODI </th>
            </tr>";
            while($row = mysql_fetch_array($sql_result)){ …
Run Code Online (Sandbox Code Playgroud)

html php mysql

1
推荐指数
1
解决办法
299
查看次数

标签 统计

html ×1

mysql ×1

php ×1