php mysql query data
//Tutorial on connecting to database
$link_id = mysql tutorial_connect("localhost","root","") or die("Connection failed");
if($link_id)
{
//Select database
mysql_select_db("my_test");
//The above is the header database connection part, which is the common part below.
if(!$_GET[id]){
//Display user list
$sql = "select * from userinfo";
$result=mysql_query($sql);
echo "
No. |
Username |
Gender |
Age |
Registration Time |
Details |
";
while($row=mysql_fetch_array($result)){
echo "
".$row[id]." |
".$row[username]." |
".$row[gender]." |
".$row[age]." |
".$row[regdate]." |
View |
";
}
echo "
";
}
else
{
//Show detailed information of the specified user
$sql="select * from userinfo where id=".$_GET[id];
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
echo "Number: ".$row[id]."
Username: ".$row[username]."
Gender: ".$row[gender]."
Age: ".$row[age]."
Registration time: ".$row['regdate'];
echo "
Continue query";
}
}//end if
?>
http://www.bkjia.com/PHPjc/630867.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630867.htmlTechArticlephp mysql query data?php tutorial //Connect to database tutorial$link_id = mysql tutorial_connect(localhost,root, ) or die (connection failed); if($link_id) { //Select database mysql_select_db(my_te...