<? Php Tutorial
// 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 "<TABLE border = 1>
<TR>
<TD> No. </TD>
<TD> user name </TD>
<TD> Gender </TD>
<TD> age </TD>
<TD> Registration time </TD>
<TD> Details </TD>
</TR> ";
While ($ row = mysql_fetch_array ($ result )){
Echo "<TR>
<TD> ". $ row [id]." </TD>
<TD> ". $ row [username]." </TD>
<TD> ". $ row [gender]." </TD>
<TD> ". $ row [age]." </TD>
<TD> ". $ row [regdate]." </TD>
<TD> <a href = query. php? Id = ". $ row [id]."> View </a> </TD>
</TR> ";
}
Echo "</TABLE> ";
}
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]. "<br> user name :". $ row [username]. "<br> gender :". $ row [gender]. "<br> Age :". $ row [age]. "<br> Registration time :". $ row ['regdate'];
Echo "<br> <a href = query. php> continue query </a> ";
}
} // End if
?>