dqc18251 2013-05-15 10:24
浏览 61

如何下拉菜单选择过滤数据查询?

<?PHP
$sql = "SELECT id as id, etkinlik_adi,etkinlik_tarihi,adiniz,soyadiniz,eposta,firma,departman,telefon,faks,cep_telefon,secim1,secim2,tarih FROM  etkinlikler  order by id ";
$result = mysql_query($sql);
if (!$result) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
   exit;
}
if (mysql_num_rows($result) == 0) {
    echo "No rows found, nothing to print so am exiting";
    exit;
}
while ($row = mysql_fetch_assoc($result)) {
$id=$row['id'];
$etkinlik_adi=$row["etkinlik_adi"];
$etkinlik_tarihi =$row["etkinlik_tarihi"];
$adiniz = $row["adiniz"];
$soyadiniz = $row["soyadiniz"];
$eposta = $row["eposta"];
$firma = $row["firma"];
$departman = $row["departman"];
$telefon = $row["telefon"];
$faks = $row["faks"];
$cep_telefon = $row["cep_telefon"];
$secim1 = $row["secim1"];
$secim2 = $row["secim2"];
$tarih = $row["tarih"];
?
}
mysql_free_result($result); 
?>

How to select filter data query with dropdownmenu results ? How to filter the data based on the selected column are query?(for example adiniz, soyadiniz, tarih ? )

  • 写回答

1条回答 默认 最新

  • doucan1979 2013-05-15 10:44
    关注

    If you have a select menu for adiniz like this

    <select name='adniz'>
    <option value="$name1"><? php echo $name1;?></option>
    <option valus="$name2"><?php echo $name2;?></option>
    ...
    </select>
    

    the query should be

    $sql = "SELECT id as id, etkinlik_adi,etkinlik_tarihi,adiniz,soyadiniz,eposta,firma,departman,telefon,faks,cep_telefon,secim1,secim2,tarih FROM  etkinlikler  WHERE adiniz='".$_POST['adiniz']."' order by id ";
    
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作