<?php
Connecting to a database
$link _id = mysql_connect ("localhost", "root", "") or Die ("Connection failed");
if ($link _id)
{
Select Database
mysql_select_db ("My_test");
The above is the header database Connection section, which is the following common section.
if (!$_get[id]) {
Show List of users
$sql = "SELECT * from Www.111cn.net";
$result =mysql_query ($sql);
echo "<table border=1>
<TR>
<TD> number </TD>
<TD> User name </TD>
<TD> Sex </TD>
<TD> Age </TD>
<TD> Registration Time </TD>
<TD>www.111cn.net</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
{
Show details for the specified user
$sql = "SELECT * from UserInfo where id=". $_get[id];
$result =mysql_query ($sql);
$row =mysql_fetch_array ($result);
echo "Number:". $row [id]. " <br> user name: ". $row [username]." <br> sex: ". $row [Gender]." <br> Ages: ". $row [age]." <br> registration Time: ". $row [' regdate '];
echo "<br><br><br><a href=query.php> continue query </a>";
}
}//end if www.111cn.net
?>