发布网友 发布时间:2022-05-01 16:48
共2个回答
懂视网 时间:2022-05-01 21:10
$db = new mysqli("localhost","root","12345678","heiheihei"); $sql = "select * from student"; $result = $db->query($sql); echo "<select>"; if($result) { while ($attr = $result->fetch_row()) { echo "<option value=‘{$attr[0]}‘> {$attr[1]}</option>"; } } echo "</select>";利用表格的格式:
<body> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>代号</td> <td>名称</td> <td>编号</td> </tr> <?php $db = new MySQLi("localhost","root","12345678","heiheihei"); $sql = "select * from cou "; $r = $db->query($sql); if($r) { while ($attr = $r->fetch_row()) { echo " <tr> <td>{$attr[0]}</td> <td>{$attr[1]}</td> <td>{$attr[2]}</td> </tr>"; } } ?> </table> </body> </html>
反正套路都差不多啦
将数据库中的信息显示在网页上
标签:网页 pre 名称 query style att student localhost result
热心网友 时间:2022-05-01 18:18
需要三个步骤:第一步,用php连接数据库;