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