我想在使用三个表格时选择mytable中的项目,并且在此页面中打开另一个ID以便打开,因此我想使用两个角色来完成获取数据的位置和位置。
<?php
$sel = "SELECT * FROM `informations` where `cate_id` =".$_GET['info_id'];
$done = mysql_query($sel);
?>
<form action="" method="post" enctype="multipart/form-data">
<label for="location"></label>
<select name="location" id="location"><?php
$sel_cate = "SELECT * FROM locations";
$done_cate = mysql_query($sel_cate);
while($get_cate = mysql_fetch_array($done_cate)){
echo '<option value="'.$get_cate['id'].'">'.$get_cate['location'].'</option>';
$loc=$get_cate['id'];
}
?>
</select>
<input type="submit" name="go" id="go" value="Go">
<input type="submit" name="all" id="all" value="Show All...">
</form>
<?php
if(isset($_POST['go'])){
$sel ='SELECT * FROM `pharmacies` WHERE `cate_id` ="'.$_GET['info_id'].'" || `location_id` = "'.$_POST['location'].'"';
?>
答案 0 :(得分:-1)
我尝试了这段代码,当isset($ _ POST ['go'])变量$ sel得到$ _GET ['info_id']和$ _POST ['location']值时。生成的查询没有错误,必须获取信息。
我没有看到你的mysql_query:if(isset($ _ POST ['go']))。也许你忘了查询:
if(isset($_POST['go']))
{
$sel = 'SELECT * FROM `pharmacies` WHERE `cate_id` ="'.addslashes($_GET['info_id']).'" or `location_id` = "'.addslashes($_POST['location']).'"';
$selRslt = mysql_query($sel);
while($row = mysql_fetch_array($selRslt))
{
var_dump($row);
}
}