21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
$conn=mysql_connect('localhost','root','');
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("project",$conn)or die(mysql_error());
mysql_query('set names UTF-8');
$rootid = $_POST['rootid'];
if(isset($_POST['Submit'])){
print_r($_POST);
//现在打印这个数组就会发现有一个 table 指向你选择的内容;只需判断table等于什么就可以了,而这个值就取决于上面的option里面的value
if($_POST['rootid'] == 'all'){
$result = mysql_query("SELECT * from job "); //查询整张表
}elseif($_POST['rootid'] == '$rootid'){
$result = mysql_query("SELECT * from job WHERE District = '$rootid' "); //按条件查询
}
//当你有多个条件的时候,这里还可以继续elseif
}
while($row = mysql_fetch_array($result))
{
echo"<tr>";
echo"<th>" . $row['Job No.'] . "</th>";
echo"<th >" . $row['Project Type'] . "</th>";
echo"<th>" . $row['Title'] . "</th>";
echo " <th> <a href='chakan.php?id=".$row['id']."');\" targer=blank>查看</a>";
echo"</tr>";
}
mysql_close($conn);
?>