选择指定条件的数据,并显示出来(select)

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("my_db", $con); //选取数据库


/////////////////////////////////查询指定name的数据
$result = mysql_query("SELECT * FROM world WHERE Name='$_POST[Name]'");
echo "<table border='1'>
<tr>
<th>id</th>
<th>name</th>
<th>location</th>
</tr>
";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Id'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Location'] . "</td>";
echo "</tr>";
}
echo "</table>";

/////////////////////////////////关闭连接
mysql_close($con);
?>

 

posted on 2010-09-18 00:12  lovening  阅读(725)  评论(0编辑  收藏  举报