php列出mysql表所有行和列的简单示例

前端之家收集整理的这篇文章主要介绍了php列出mysql表所有行和列的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP列出MysqL表的所有行和列感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!

/**
 * 列出MysqL表的所有行和列
 *
 * @param 
 * @arrange 512-笔记网: www.512Pic.com
 **/
$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 );

/***   来自编程之家 jb51.cc(jb51.cc)   ***/

猜你在找的PHP相关文章