-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnum.php
More file actions
18 lines (18 loc) · 699 Bytes
/
num.php
File metadata and controls
18 lines (18 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$con=mysql_connect("localhost:3306", "root", "") // it's equvialent to terminal command: mysql -u root -p
or die("fail to connect mysql database!<br>");
mysql_select_db("mysql_test1", $con) or die("fail to choose database!<br>"); //it's equvialent to sql: use mysql_test1
mysql_query("set names 'gbk'");
$sql="SELECT * FROM customers";
$sql=$sql." WHERE cust_sex='F'";
$result=mysql_query($sql,$con); // it's equvialent to sql: SELECT * FROM customers WHERE cust_sex='F';
if($result)
{
echo "query successfully!<br>";
$num=mysql_num_rows($result);
echo "nihao, alice <br>";
echo "the number of female customer in database mysql_test1 is: ".$num;
}
else
echo "failed to query";
?>