按照下拉菜单选出的字段名,然后在文本框中输入要查询字段的信息
$txt_sousuo=$_POST['txt_sousuo'];
$ziduan=$_POST['ziduan'];
if($ziduan!='' && $txt_sousuo!=''){
echo "<table border=1 width=700>";
echo "<tr bgcolor=#0099CC><th>hotel_id</th><th>start_date</th><th>end_date</th><th>content</th><th>source</th><th>s_type</th><th>操作</th></tr>";
//查询数据$query = "SELECT * FROM hotel_activities_2 where '{$ziduan}' like '%{$txt_sousuo}%'";
$result=mysql_query($query) or die("查询失败");
if (mysql_num_rows($result)>0){
//循环输出表中各个字段值
while ($row = mysql_fetch_array($result)) {
echo '<tr>';
echo '<td>'.$row['hotel_id'].'</td>';
echo '<td>'.$row['start_date'].'</td>';
echo '<td>'.$row['end_date'].'</td>';
echo '<td>'.$row['content'].'</td>';
echo '<td>'.$row['source'].'</td>';
echo '<td>'.$row['s_type'].'</td>';
echo '<td>'.' <a href="delect_sj.php?hid='.$row['h_id'].'" onclick="return delconfirm()">删除</a> '.' <a href="upedit.php?hid='.$row['h_id'].'" >编辑</a> '.'</td>';
echo '</tr>';
}
echo "</table>";
}}
mysql_close($connection); //关闭与数据库的连接
$txt_sousuo=$_POST['txt_sousuo'];
$ziduan=$_POST['ziduan'];
if($ziduan!='' && $txt_sousuo!=''){
echo "<table border=1 width=700>";
echo "<tr bgcolor=#0099CC><th>hotel_id</th><th>start_date</th><th>end_date</th><th>content</th><th>source</th><th>s_type</th><th>操作</th></tr>";
//查询数据$query = "SELECT * FROM hotel_activities_2 where '{$ziduan}' like '%{$txt_sousuo}%'";
$result=mysql_query($query) or die("查询失败");
if (mysql_num_rows($result)>0){
//循环输出表中各个字段值
while ($row = mysql_fetch_array($result)) {
echo '<tr>';
echo '<td>'.$row['hotel_id'].'</td>';
echo '<td>'.$row['start_date'].'</td>';
echo '<td>'.$row['end_date'].'</td>';
echo '<td>'.$row['content'].'</td>';
echo '<td>'.$row['source'].'</td>';
echo '<td>'.$row['s_type'].'</td>';
echo '<td>'.' <a href="delect_sj.php?hid='.$row['h_id'].'" onclick="return delconfirm()">删除</a> '.' <a href="upedit.php?hid='.$row['h_id'].'" >编辑</a> '.'</td>';
echo '</tr>';
}
echo "</table>";
}}
mysql_close($connection); //关闭与数据库的连接
$txt_sousuo=$_POST['txt_sousuo'];
$ziduan=$_POST['ziduan'];
收到的值对不对。再确认SQL语句在数据库中执行有没有结果。还有没看见数据库连接的语句啊.