php列出mysql表所有行和列的方法
更新時(shí)間:2015年03月13日 15:41:38 作者:work24
這篇文章主要介紹了php列出mysql表所有行和列的方法,涉及php操作mysql數(shù)據(jù)庫(kù)的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了php列出mysql表所有行和列的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
復(fù)制代碼 代碼如下:
<html>
<head>
<title>Selecting Data</title>
</head>
<body>
<?php
$user = "root";
$pass = "";
$db = "mydatabase";
$link = mysql_connect( "localhost", $user, $pass );
if ( ! $link ) {
die( "Couldn't connect to MySQL: ".mysql_error() );
}mysql_select_db( $db, $link ) or die ( "Couldn't open $db: ".mysql_error() );$result = mysql_query( "SELECT * FROM domains where sex='F'" );
$num_rows = mysql_num_rows( $result );print "<p>$num_rows women have added data to the table</p>\n";print "<table>";
while ( $a_row = mysql_fetch_row( $result ) ) {
print "<tr>";
foreach ( $a_row as $field ) {
print "<td>".stripslashes($field)."</td>";
}
print "</tr>";
}
print "</table>";
mysql_close( $link );
?>
</body>
</html>
<head>
<title>Selecting Data</title>
</head>
<body>
<?php
$user = "root";
$pass = "";
$db = "mydatabase";
$link = mysql_connect( "localhost", $user, $pass );
if ( ! $link ) {
die( "Couldn't connect to MySQL: ".mysql_error() );
}mysql_select_db( $db, $link ) or die ( "Couldn't open $db: ".mysql_error() );$result = mysql_query( "SELECT * FROM domains where sex='F'" );
$num_rows = mysql_num_rows( $result );print "<p>$num_rows women have added data to the table</p>\n";print "<table>";
while ( $a_row = mysql_fetch_row( $result ) ) {
print "<tr>";
foreach ( $a_row as $field ) {
print "<td>".stripslashes($field)."</td>";
}
print "</tr>";
}
print "</table>";
mysql_close( $link );
?>
</body>
</html>
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
您可能感興趣的文章:
- php empty函數(shù)判斷mysql表單是否為空
- PHP獲取mysql數(shù)據(jù)表的字段名稱和詳細(xì)信息的方法
- PHP 獲取MySQL數(shù)據(jù)庫(kù)里所有表的實(shí)現(xiàn)代碼
- php獲取mysql數(shù)據(jù)庫(kù)中的所有表名的代碼
- PHP表單數(shù)據(jù)寫(xiě)入MySQL數(shù)據(jù)庫(kù)的代碼
- 防止MySQL注入或HTML表單濫用的PHP程序
- php mysql獲取表字段名稱和字段信息的三種方法
- PHP操作mysql數(shù)據(jù)庫(kù)分表的方法
- php+mysqli實(shí)現(xiàn)批量替換數(shù)據(jù)庫(kù)表前綴的方法
- php+mysql+ajax實(shí)現(xiàn)單表多字段多關(guān)鍵詞查詢的方法
- php檢測(cè)mysql表是否存在的方法小結(jié)
相關(guān)文章
學(xué)習(xí)php設(shè)計(jì)模式 php實(shí)現(xiàn)命令模式(command)
這篇文章主要介紹了php設(shè)計(jì)模式中的命令模式,使用php實(shí)現(xiàn)命令模式,感興趣的小伙伴們可以參考一下2015-12-12Thinkphp和onethink實(shí)現(xiàn)微信支付插件
這篇文章主要為大家詳細(xì)介紹了Thinkphp和onethink實(shí)現(xiàn)微信支付插件,感興趣的小伙伴們可以參考一下2016-04-04

有關(guān)JSON以及JSON在PHP中的應(yīng)用
簡(jiǎn) 單地說(shuō),JSON 可以將 JavaScript 對(duì)象中表示的一組數(shù)據(jù)轉(zhuǎn)換為字符串,然后就可以在函數(shù)之間輕松地傳遞這個(gè)字符串,或者在異步應(yīng)用程序中將字符串從 Web 客戶機(jī)傳遞給服務(wù)器端程序。
2010-04-04 
ThinkPHP中自定義目錄結(jié)構(gòu)的設(shè)置方法
現(xiàn)在很多朋友喜歡使用ThinkPHP但它會(huì)生成的很多目錄有些朋友不喜歡,這里為大家分享下將目錄都放到include目錄的方法,這樣就干凈多了
2014-08-08