Home > Backend Development > PHP Tutorial > PHP reads database records based on parameters_PHP tutorial

PHP reads database records based on parameters_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:05:00
Original
1239 people have browsed it

php reads database records from the database based on parameters This is a PHP method for reading database records, but we have done a deeper processing, that is, querying the parameters passed by the user's URL address bar from the database, such as user login, registration, adding records, and news display. Come on.

php tutorial to read database tutorial records from the database according to parameters
This is a PHP method for reading database records, but we have done a deeper processing, that is, querying the parameters passed by the user's URL address bar from the database, such as user login, registration, adding records, and news display. Come on.
*/

$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()."
The sql that caused the problem: ".$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 the record of id=2

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630823.htmlTechArticlephp reads database records from the parameters according to the parameters. This is a php to read the database records. It is just our deeper operation. The processing is to check the parameters passed by the user's URL address bar from the database...
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template