mysqli查询显示表中的所有内容

时间:2017-10-03 08:15:16

标签: php html mysqli html-table display

我对此非常陌生,包括这个社区,所以我将欣赏最简单的答案和令人难忘的细分。我有以下代码:

    <?php
$link = mysqli_connect("localhost", "demo_lesson", "live@lesson1", 
"demo_lesson");

/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}


/* Select all return result  */
if ($result = mysqli_query($link, "SELECT * FROM resulttable where id != '0' 
ORDER BY id DESC") ) {





    $row = mysqli_fetch_array($result);
    $id = $row["id"];
    $email = $row["email"];
    $phone= $row["phone"]; 
    $ip = $row["ip"];
    $date = $row["date"]; 

   echo '<table width = "100%" border = "1" cellspacing = "1" cellpadding = 
  "1">    
   <caption><h1>List of all Results from result Table</h1></caption>
  <thead>
  <tr>
  <th>Id</th>
  <th>Email</th>
  <th>Phone</th>
  <th>Ip</th>
  <th>Date</th>
  </tr>
  </thead>
  <tbody>
  <tr>

  <td> <center> '. $row['id'] .' </center></td>
  <td> <center> '. $row['email'] .' </center></td>
  <td> <center> '. $row['phone'] .' </center></td>
  <td> <center> '. $row['ip'] .' </center></td>
  <td> <center> '. $row['date'] .' </center></td>
  </tr>
  </tbody>
  </table>';
  } else {'<p>There are currently no resulttable in the system.</p>';}

  $result->free();
  mysqli_close($link);
  ?>

我已经进行了搜索并找到了迄今为​​止帮助我的答案,但我无法解决这个问题。我得到的只是一行结果,而不是表格中的所有内容。

0 个答案:

没有答案