0
這裏是我的表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>
這裏是suggestionforjobs.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"
我需要的是什麼? 如果我在選擇框中選擇一個值,它應該傳入查詢(c.category_name LIKE'%$ catname%'),以便在腳本中編寫一些代碼,除catname:「」+ selectString +「」 )在腳本中。 所以任何人都可以用完美的jQuery腳本幫助我。 thanku提前
這是什麼 「在mysql中提到的組合框的標籤」 是指 – 2013-03-14 04:50:17
AND(db_column名)LIKE '%$值%' ORDER BY JOB_ID – Krishnaram 2013-03-14 05:00:06