这来自我的表单字段:
$subject="physics with maths";
这是在我的数据库中:
$keywordsindatabse="(physics && electronics) || (electronics & communication) || (electronics and communication)";
在提交表单时,我想将条件$keywordsindatabse
与$subject
. 有任何想法吗?
任何帮助将不胜感激。
代码:
<form id="myform" name="myform">
<select name="sselect" id="itmn">
<option value="">Select</option>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
</select>
<input type='text' name='gmajorsub' id=""" value="" onblur="chkdegree(document.getElementById('itmn').value,this.value);">
</form>
<script>
function chkdegree(item_id,keyword)
{
$.ajax({
type: "GET",
url: "degree_match.php",
dataType: 'html',
data: {item_id : item_id,keyword : keyword},
success: function(data){
if(data=="0")
{
alert("Dear Applicant, You are not allowed to register.You Subject not matching our essential qualification requirements.");
document.getElementById("gmajorsub").value="";
document.getElementById("gmajorsub").focus();
return false;
}
}
});
}
</script>
度匹配.php:
<?php
include("../../lib/dbc/dbConnection.php");
require('../../lib/dbc/commonFunc.php');
require('../../lib/dbc/dbHandler.class.php');
$dbObject = new dbHandler();
$dbObject->connect();
$query="select * from advt_110_post_details where recNo='".$_REQUEST['item_id']."'";
$result=mysql_query($query);
$num=mysql_fetch_array($result);
$keyword=strtolower($_REQUEST['keyword']);
$degree=$num['subject_keywords'];
$degree1=explode("|",$degree);
$max = array(null, 0); // category, occurences
/*foreach($degree1 as $k => $v) {
$replaced = str_replace($v, '##########', $keyword);
preg_match_all('/##########/i', $replaced, $matches);
if(count($matches[0]) > $max[1]) {
$max[0] = $k;
$max[1] = count($matches[0]);
}
}
if($max[1]>=count($degree1))
{
echo"1";
}
else{
echo"0";
}
*/
/*foreach($degree1 as $k => $v) {
if ( strstr( $membership, "member" ) )
{
}
}
*/
?>