WEB安全基础-PHP+MySQL实践
生活随笔
收集整理的這篇文章主要介紹了
WEB安全基础-PHP+MySQL实践
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
MySQL數據庫詳細信息如下:
test2.php源碼:
<html> <body> <h1>MySQL測試</h1> <font size="4" color="black">學生列表如下</font><br> <?phpfunction ShowTable($table_name){$conn=mysql_connect("localhost","root","root");if(!$conn){echo "連接失敗";}mysql_select_db("websecurity",$conn);mysql_query("set names utf8");$sql="SELECT * FROM $table_name ORDER BY age ASC;";$res=mysql_query($sql,$conn);$rows=mysql_affected_rows($conn);//獲取行數$colums=mysql_num_fields($res);//獲取列數 echo "<table style='border-color: #efefef;' border='1px' cellpadding='5px' cellspacing='0px'><tr>";for($i=0; $i < $colums; $i++){$field_name=mysql_field_name($res,$i);echo "<th>$field_name</th>";}echo "</tr>";while($row=mysql_fetch_row($res)){echo "<tr>";for($i=0; $i<$colums; $i++){echo "<td>$row[$i]</td>";}echo "</tr>";}echo "</table>";}ShowTable("student"); ?> </body> </html>網站運行截圖如下:
總結
以上是生活随笔為你收集整理的WEB安全基础-PHP+MySQL实践的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 6.2二叉树及二叉树存储结构
- 下一篇: mysql查询1971年以前_mysql