Home  >  Article  >  Backend Development  >  php mysql query data_PHP tutorial

php mysql query data_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:04:19925browse

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 "









";

while($row=mysql_fetch_array($result)){
echo "








";
}
echo "
No. Username Gender Age Registration Time Details
".$row[id]." ".$row[username]." ".$row[gender]." ".$row[age]." ".$row[regdate]." View
";
}
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
?>

www.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...
Statement:
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