Php reads database records based on parameters _ PHP Tutorial

Source: Internet
Author: User
Php reads database records based on parameters. Php reads database records from the database based on parameters. this is a php read database record, but we have processed it in a deeper layer, it is to read the database records from the php database based on the parameters of the parameters passed in the user url address bar. this is a php database reading record, but we have processed it in a deeper layer, it is used to query the parameters passed in the user url address bar from the database, such as user login, registration, adding records, and news display.

Php tutorials read database tutorial records based on parameters
This is a php database reading record, but we have processed it more deeply, that is, to query the parameters passed in the user url address bar from the database, for example, user login, registration, added records and used for news display.
*/

$ Host = 'localhost ';
$ User_name = 'root ';
$ Password = 'admin ';
$ Id = $ _ get ['id'];
$ Conn = mysql tutorial _ connect ($ host, $ user_name, $ password );
If (! $ Conn)
{
Die ('database connection failed: '. mysql_error ());
}
Mysql_select_db ('test ');

$ SQL = 'SELECT id, name, city from users where id = '. $ id;

$ Result = mysql_query ($ SQL) or die ("
Error:". Mysql_error ()."
Problematic SQL: ". $ SQL );

If ($ num = mysql_num_rows ($ result ))
{
Echo'

';
While ($ row = mysql_fetch_array ($ result, mysql_assoc ))
{
Print_r ($ row );
}
}
Else
{
Echo 'The data you want to query already exists ';
}

Mysql_close ($ conn );
?>
Query records with id = 2

The handler reads database records, but we perform further processing, that is, we can retrieve the parameters passed in the user url address bar from the database...

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.