<?php
$db_host='localhost';
$db_database='test';
$db_username='root';
$db_password='root';
$connection=mysql_connect($db_host,$db_username,$db_password);//连接到数据库
mysql_query("set names 'utf8'");//编码转化
if(!$connection){
die("could not connect to the database:</br>".mysql_error());//诊断连接错误
}
$db_selecct=mysql_select_db($db_database);//选择数据库
if(!$db_selecct)
{
die("could not to the database</br>".mysql_error());
}
$query="select * from a_user ";//构建查询语句
$result=mysql_query($query);//执行查询
if(!$result)
{
die("could not to the database</br>".mysql_error());
}
// array mysql_fetch_row(resource $result);
while($result_row=mysql_fetch_row(($result)))//取出结果并显示
{
echo "<tr>";
echo "<td>$result_row[0]</td>";
echo "<td>$result_row[1]</td>";
echo "<td>$result_row[2]</td>";
echo "<td>$result_row[3]</td>";
echo "<td>$result_row[4]</td>";
echo "<td>$result_row[5]</td>";
echo "</tr>";
}
mysql_close($connection);//关闭连接
?>
$db_host='localhost';
$db_database='test';
$db_username='root';
$db_password='root';
$connection=mysql_connect($db_host,$db_username,$db_password);//连接到数据库
mysql_query("set names 'utf8'");//编码转化
if(!$connection){
die("could not connect to the database:</br>".mysql_error());//诊断连接错误
}
$db_selecct=mysql_select_db($db_database);//选择数据库
if(!$db_selecct)
{
die("could not to the database</br>".mysql_error());
}
$query="select * from a_user ";//构建查询语句
$result=mysql_query($query);//执行查询
if(!$result)
{
die("could not to the database</br>".mysql_error());
}
// array mysql_fetch_row(resource $result);
while($result_row=mysql_fetch_row(($result)))//取出结果并显示
{
echo "<tr>";
echo "<td>$result_row[0]</td>";
echo "<td>$result_row[1]</td>";
echo "<td>$result_row[2]</td>";
echo "<td>$result_row[3]</td>";
echo "<td>$result_row[4]</td>";
echo "<td>$result_row[5]</td>";
echo "</tr>";
}
mysql_close($connection);//关闭连接
?>