欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP MySQL Where子句学习

程序员文章站 2022-03-17 17:35:35
...
  1. $con = mysql_connect("localhost","peter","abc123");

  2. if (!$con)
  3. {
  4. die('Could not connect: ' . mysql_error());
  5. }
  6. mysql_select_db("my_db", $con);

  7. $result = mysql_query("SELECT * FROM Persons

  8. WHERE FirstName='Peter'");
  9. while($row = mysql_fetch_array($result))

  10. {
  11. echo $row['FirstName'] . " " . $row['LastName'];
  12. echo "
    ";
  13. }
  14. ?>

复制代码

输出: Peter Griffin