php之mysql操作

一、连接,插入,查询
<?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);

?>

你可能感兴趣的:(mysql,PHP)