0

这是我的表1

表格1

这是我的表2 在此处输入图像描述

这是选择字段和输入搜索字段的表单

<form name="search_form" method="get" action="">
    <div class="search_job">
        <div class="heading">
            Search Jobs:
        </div>
        <?php $jobcat = DAOFactory::getTblCategoriesDAO()->queryAll();
        ?>
        <select name="loctopcities" id="loctopcities" class="job_place_input" >
            <option value="" >Select Job Type</option>
            <?php for($k=0;$k<count($jobcat);$k++){
            ?>
            <option id = "catName" value="<?php echo $jobcat[$k]->categoryName; ?>" ><?php echo $jobcat[$k]->categoryName; ?></option>
            <?php } ?>
        </select>
        <input  class="job_area_input populate" name="key" id="key"  type="text"  onKeyUp="suggest_jobs(this.value);" onBlur="fill_reguser();" >
        <input name="btn_submit" value="Search" class="search_button" type="submit" >
        <div class="suggestionsBox" id="suggestions" style="display: none;">
            <div class="suggestionList" id="suggestionsList">
            </div>
        </div>
    </div>
</form>

这是搜索建议的脚本

<script>
function suggest_jobs(inputString,selectString){
    if(inputString.length == 0 ){
        $('#suggestions').fadeOut();
    } else {
        $('#key').addClass('load')
        $('#catName').addClass('load')
        $.post("suggestionforjobs.php", {queryString: ""+inputString+"",catName: ""+selectString+""}, function(data){
            //alert("testing : "+data+" :: data length : "+data.length)
            if(data.length >10) {
                $('#suggestions').fadeIn()
                $('#suggestionsList').html(data)
                $('#key').removeClass('load')
                $('#catName').removeClass('load')
            } else {
                $('#suggestions').fadeOut()
                $('#key').removeClass('load')
                $('#catName').removeClass('load')
            }
        });
    }
}
function fill_reguser(thisValue) {
    $('#key').val(thisValue);
    setTimeout("$('#suggestions').fadeOut();", 1000);
}
</script>

这是suggestforjobs.php的代码

<?php
include_once("include_dao.php");
if(isset($_POST['queryString']) ||  isset($_POST['catName']) ) 
{
    $value = $_POST['queryString'];
    $catname = $_POST['catName'];
    if(strlen($queryString) >0) 
    {
        $c = DAOFactory::getTblJobsDAO()->querysearchjobs($value,$catname);
        $countm=count($c);
        if($c) 
        {
            echo '<ul>';
            for($m=0;$m<$countm;$m++)
            {
            ?>
            <li onClick="fill_reguser('
            <?PHP echo $c[$m]->jobPosition; ?>')">
                <?PHP echo $c[$m]->jobPosition; ?> 
            </li>
            <?php
            }
            echo '</ul>';
        } else {
            echo 'No Related Search Content Available with this starting letter';
        }
    } else {
        // do nothing
    }
} else {
    echo 'There should be no direct access to this script!';
}
?>

我的查询是:

SELECT * FROM tbl_jobs cc INNER JOIN tbl_categories c ON cc.job_category_id = c.category_id WHERE job_position LIKE '%$value%' AND c.category_name LIKE '%$catname%' ORDER BY job_id"

我需要的是:如果我在选择框中选择一个值,它应该传递query(c.category_name LIKE '%$catname%')给要在脚本中编写的一些代码,除了catName: ""+selectString+""在脚本中一切正常。

4

1 回答 1

0
SELECT * FROM tbl_jobs cc INNER JOIN tbl_categories c ON cc.job_category_id = c.category_id WHERE job_position LIKE '%$value%' AND (column name) LIKE '%$value%' ORDER BY job_id"
于 2013-03-14T04:46:27.517 回答