これは私のフォームフィールドから来ています:
$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>
degree_match.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" ) )
{
}
}
*/
?>