//连接
$link = mysql_connect("mysql_host", "mysql_login", "mysql_password")
or die ("Could not connect to MySQL");
or die ("Could not connect to MySQL");
mysql_select_db ("my_database")
or die ("Could not select database");
or die ("Could not select database");
//查询/
$query = "SELECT * FROM my_table";
$result = mysql_query ($query)
or die ("Query failed");
$result = mysql_query ($query)
or die ("Query failed");
// printing HTML result
//打印///
print "<table>/n";
while ($line = mysql_fetch_row($result)) {
print "/t<tr>/n";
while(list($col_name, $col_value) = each($line)) {
print "/t/t<td>$col_value</td>/n";
}
print "/t</tr>/n";
}
print "</table>/n";
while ($line = mysql_fetch_row($result)) {
print "/t<tr>/n";
while(list($col_name, $col_value) = each($line)) {
print "/t/t<td>$col_value</td>/n";
}
print "/t</tr>/n";
}
print "</table>/n";
//关闭连接///
mysql_close($link);
函数
mysql_num_rows 返回结果集的行数