當前位置:編程學習大全網 - 網站源碼 - PHP 怎麽顯示數據庫中的數據 求源代碼

PHP 怎麽顯示數據庫中的數據 求源代碼

讀數據庫,以表格輸出的示例代碼:

<?php

header('Content-type:text/html;charset=utf-8');

$db = new mysqli('localhost','root','root','books');

$rows = $db->query('SELECT * FROM customers');

echo '<table border="1"><tr><td>姓名</td><td>年齡</td></tr>';

while($row = $rows->fetch_assoc()){

echo '<tr><td>'.$row['name'].'</td>';

echo '<td>'.$row['address'].'</td></tr>';

}

?

  • 上一篇:千龍短線軟件簡介
  • 下一篇:fscanf的源代碼分析
  • copyright 2024編程學習大全網