(1)登录phpmyadmin之后,新建test数据表,新建db_id int,db_name varchar ;
(2)在网站目录新建index.php
(3)输入
<html>
<head>hello</head>
<body>
<?php
$con = mysql_connect("localhost","root","xxxxxxxx");
if(!$con)
{
die('数据库链接失败:'.mysql_error());
}
else
{
mysql_select_db("test",$con);
$ $data = mysql_query("insert into test2(db_id,db_name) values (1,'Bobo')");
$result = mysql_query("SELECT db_id,db_name FROM test2");
echo"<table border='1'>
<tr>
<th>db_id</th>
<th>db_name</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo"<tr>";
echo"<td>" . $row['db_id'] . "</td>";
echo"<td>" . $row['db_name'] . "</td>";
echo"</tr>";
}
echo"</table>";
}
mysql_close($con);
?>
</body>
</html>
执行完成!