当前位置:Gxlcms > PHP教程 > php的查询功能(怎么通过查询条件获取相应表的字段)

php的查询功能(怎么通过查询条件获取相应表的字段)

时间:2021-07-01 10:21:17 帮助过:23人阅读

php的查询功能(如何通过查询条件获取相应表的字段)
//获得连接
$db = mysql_connect("localhost", "root", "root") or die(mysql_error());
//echo "Connected to MySQL
";
//连接数据库
mysql_select_db("test") or die(mysql_error());
//echo "Connected to Database";

//查询数据,并用表格显示出来
@$checked = $_POST['checked'];
@$result = mysql_query("select * from books",$db);
echo "\n";
echo "




";
echo "\n";
//循环遍历
while ($myrow = mysql_fetch_row($result)){
printf("



", $myrow[0], $myrow[1],$myrow[2],$myrow[3]);
}
echo "
isbn author title price
%s %s %s %s
\n";
?>



无标题文档





------解决方案--------------------
result = mysql_query("select * from books where checked=‘$checked’ ");
------解决方案--------------------
if(isset($_POST['checked'])){
@$result = mysql_query("select * from books",$db);
echo "\n";
echo "




";
echo "\n";
//循环遍历

人气教程排行

isbn author title price