PHP MySQL database operation tutorial in this tutorial three examples are about PHP operation MySQL Database tutorial, one is to connect MySQL database, the second is to query the database field name, the third is to query database records.
PHP Tutorial MySQL Tutorial database tutorial Operation Tutorial
This tutorial is about three examples of PHP operation MySQL Database tutorial, one is to connect MySQL database, the second is to query the database field name, and the third is to query database records.
*/
Connect to MySQL Database
$link = mysql_connect ("localhost", "Mysql_user", "Mysql_password")
Or Die ("Could not connect:". Mysql_error ());
Print ("connected successfully");
Mysql_close ($link);
Querying MySQL field names
$link = mysql_connect (' localhost ', ' mysql_user ', ' Mysql_password ');
$fields = Mysql_list_fields ("Database1", "table1", $link);
$columns = Mysql_num_fields ($fields);
for ($i = 0; $i < $columns; $i + +) {
Echo Mysql_field_name ($fields, $i). "N";
}
Querying data
$conn =mysql_connect ("localhost", "phpdb", "phpdb")
Or Die ("Cannot connect to database server:". mysql_error ());
mysql_select_db ("Test", $conn) or Die ("Cannot select Database:". mysql_error ());
$result = mysql_query ("SELECT * from User", $conn);
while ($row =mysql_fetch_array ($result)) {
Print "Name:". $row [1];
Print "Address:". $row [3];
Print "Tel:". $row [4];
print "Email:". $row [5];
Echo
"
";
}
http://www.bkjia.com/PHPjc/630809.html www.bkjia.com true http://www.bkjia.com/PHPjc/630809.html techarticle PHP MySQL Database operation Tutorial This tutorial is about three examples are about PHP operation MySQL Database tutorial, one is to connect MySQL database, the second is to query the database field name, the third is the number of queries ...