标签:网页 pre 名称 query style att student localhost result
用下拉列表的方式输出在网页上,都在php格式里面便可以输出:
<body> <?php $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
原文地址:http://www.cnblogs.com/xuan584521/p/6416860.html