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"
| No. |
User name |
Gender |
Age |
Registration time |
Details |
";
| ". $ Row [id]." |
". $ Row [username]." |
". $ Row [gender]." |
". $ Row [age]." |
". $ Row [regdate]." |
View |
";}Echo"
";
}
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...