duanqiechui2378 2016-02-16 10:59
浏览 27

使用数据库中的选择框过滤结果的问题

I have problem with the filtering of the results i get from MYSQL database. Its using ajax and are filtering whree variables; city, category and subcategory.

It should work in this chosen order of filtering. First city, then category and then subcategory. Now is the link between city and category not working.

You can see what it looks like now: www.dittarbeid.no

Heres the ajax/Mysql call:

if($category_id=='' && $subcat_id=='' && $town_id!='' && $area_id==''){

$sql="SELECT * FROM joblisting where jobstatus='confirmed' and displaystatus='enable' and paidstatus='Yes' and jobdescription<>'' and Date_Add(paymentdate,INTERVAL 30 day)>$today and area='$area_id' and category='$category_id' order by jobID desc LIMIT 0,39";

And heres how the menu for town is set up and how they fetch the listings:

      <select id="city" style="background: url('asstes/barnsje.png') repeat-x center;" onchange="get_jobs_listed(); load_job_listed('area');$('#stown_cat').val(this.value);">
  <option value="">Velg By</option>    

                        <?php $area_res=  mysql_query("select * from municipality2 order by txt asc"); 
                              while($area_row=  mysql_fetch_array($area_res)){  
                              if($_SESSION["stown_cat"]==$area_row['id'])
                                        {
                                         echo '<option value="' . $area_row['id'] . '"selected>' . $area_row['txt'] . "</option>";
                                        }
                                       else
                                       echo '<option value="' . $area_row['id'] . '">' . $area_row['txt'] . "</option>";
                                        }   

                        ?>



</select>

and category:

<select id="select_category" onchange="load_subcategory(this.value); $('#main_cat').val(this.value);" onclick="get_jobs_listed(this.value); load_job_listed('category')load_subcategory(this.value); ">
    <option value="">Velg Kategori</option>
  <?php $category_res=  mysql_query("select * from category order by categoryName ASC"); 
                              while($category_row=  mysql_fetch_array($category_res)){ 
                                     if($_SESSION["main_cat"]==$category_row['category_ID'])
                                        {
                                         echo '<option value="' . $category_row['category_ID'] . '"selected>' . $category_row['categoryName'] . "</option>";
                                        }
                                       else
                                       echo '<option value="' . $category_row['category_ID'] . '">' . $category_row['categoryName'] . "</option>";
                                        }
                                      ?>              





</select>  

and subcategory

<select id="subcategory" style="background: url('asstes/barnsje.png') repeat-x center;" onchange="load_job_listed('subcategory');$('#smain_cat').val(this.value);">

          <option value="">Velg Subkategori</option>      

                        <?php $subcategory_res=  mysql_query("select * from subcategory order by subcategoryname asc"); 
                              while($subcategory_row=  mysql_fetch_array($subcategory_res)){  
                              if($_SESSION["smain_cat"]==$subcategory_row['subcategoryID'])
                                        {
                                         echo '<option value="' . $subcategory_row['subcategoryID'] . '"selected>' . $subcategory_row['subcategoryname'] . "</option>";
                                        }
                                       else
                                       echo '<option value="' . $subcategory_row['subcategoryID'] . '">' . $subcategory_row['subcategoryname'] . "</option>";
                                        }
                                     ?>




</select>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 winform的chart曲线生成时有凸起
    • ¥15 msix packaging tool打包问题
    • ¥15 finalshell节点的搭建代码和那个端口代码教程
    • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
    • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥120 计算机网络的新校区组网设计
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录