Phpmysql data query _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Phpmysql queries data. How does phpmysql query data? Php connection database tutorial $ link_idmysql tutorial _ connect (localhost, root,) ordie (connection failed); if ($ link_id) {select database mysql_select_db (my_te php mysql to query data

// Database connection tutorial
$ Link_id = mysql tutorial _ connect ("localhost", "root", "") or die ("connection failed ");
If ($ link_id)
{
// Select a database
Mysql_select_db ("my_test ");
// The above is the connection part of the header database, which is the public part below.
If (! $ _ GET [id]) {

// Display the user list
$ SQL = "select * from userinfo ";
$ Result = mysql_query ($ SQL );

Echo"









While ($ row = mysql_fetch_array ($ result )){
Echo"










"; ";}Echo"
No. User name Gender Age Registration time Details
". $ Row [id]." ". $ Row [username]." ". $ Row [gender]." ". $ Row [age]." ". $ Row [regdate]." View
";
}
Else
{
// Display the details of a specified user
$ SQL = "select * from userinfo where id =". $ _ GET [id];
$ Result = mysql_query ($ SQL );
$ Row = mysql_fetch_array ($ result );
Echo "No.:". $ row [id]."
Username: ". $ row [username]."
Gender: ". $ row [gender]."
Age: ". $ row [age]."
Registration time: ". $ row ['regdate'];

Echo"


Continue to query ";
}
} // End if
?>

Http://www.bkjia.com/PHPjc/630867.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630867.htmlTechArticlephp mysql Query data? Php Tutorial // database connection tutorial $ link_id = mysql tutorial _ connect (localhost, root,) or die (connection failure); if ($ link_id) {// select the database mysql_select_db (my_te...

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.