Re: 請教PHP

看板Web_Design作者 (我現在是虛擬ip…)時間20年前 (2004/07/05 06:42), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
http://linux.tnc.edu.tw/techdoc/php/php_big5/ref.mysql.html <?php /* 連接選擇資料庫 */ $link = mysql_connect("mysql_host", "mysql_user", "mysql_password") or die("Could not connect"); print "Connected successfully"; mysql_select_db("my_database") or die("Could not select database"); /* 執行 SQL 查詢 */ $query = "SELECT * FROM my_table"; $result = mysql_query($query) or die("Query failed"); /* 在 HTML 中顯示結果 */ print "<table>\n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { print "\t<tr>\n"; foreach ($line as $col_value) { print "\t\t<td>$col_value</td>\n"; } print "\t</tr>\n"; } print "</table>\n"; /* 釋放資源 */ mysql_free_result($result); /* 斷開連接 */ mysql_close($link); ?> 應該有點用 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.229.205.231

218.167.172.85 07/05, , 1F
可以了! 謝謝!!
218.167.172.85 07/05, 1F
文章代碼(AID): #10w8VLeL (Web_Design)