Simple PHP Query Database statement Instance code

Source: Internet
Author: User
Tags mysql tutorial php tutorial

This tutorial is helpful for beginners, we talked about database tutorials and used the MySQL tutorial _query,mysql_num_rows,mysql_fetch_row three functions to read and output records.

<title>selecting data</title>
<body>
<?php Tutorial
$user = "root";
$pass = "";
$db = "MyDatabase";
$link = mysql_connect ("localhost", $user, $pass);
if (! $link) {
Die ("couldn ' t connect to MySQL:". Mysql_error ());
}

mysql_select_db ($db, $link) or Die ("couldn ' t open $db:". Mysql_error ());

$result = mysql_query ("select * from domains where sex= ' F '");
$num _rows = mysql_num_rows ($result);

Print "<p> $num _rows www.111cn.net women have added data to the Table</p>n";

Print "<table>";
while ($a _row = Mysql_fetch_row ($result)) {
  print "<tr>";
  foreach ($a _row as $field {
    print <td>. Strips Tutorial Lashes ($field). " </td> ";
 }
  print "</tr>";
}
Print "</table>";
Mysql_close ($link);

</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.