一、连接,插入,查询
<?php
$con = mysql_connect("localhost","name","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("person", $con);
mysql_query("INSERT INTO user (name, password) VALUES ('Peter', '518518')");
mysql_query("INSERT INTO user (name, password) VALUES ('Glenn', '518518')");
$result = mysql_query("SELECT * FROM user");
while($row = mysql_fetch_array($result))
{
echo $row['name'] . " " . $row['password'];
echo "<br />";
}
mysql_close($con);
?>
<?php
$con = mysql_connect("localhost","name","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("person", $con);
mysql_query("INSERT INTO user (name, password) VALUES ('Peter', '518518')");
mysql_query("INSERT INTO user (name, password) VALUES ('Glenn', '518518')");
$result = mysql_query("SELECT * FROM user");
while($row = mysql_fetch_array($result))
{
echo $row['name'] . " " . $row['password'];
echo "<br />";
}
mysql_close($con);
?>