By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,303 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,303 IT Pros & Developers. It's quick & easy.

candidate search, blanks page, problem...

100+
P: 127
BElow is my php code for candidate search, it have 4 criteria which is academic background, functional experience, preferred location and languages ability. but it show yhe blanks page..
Emm, is it becase of the languages ability is at checkbox, so cannot display the profile...
Can someone give me a guildeline... Thanks..


[PHP]<?php
//required file for database connection
include("config.php");
if (isset($_POST['aBackground'])) {
$aBackground = mysql_real_escape_string($_POST["aBackground"]);
$fExperience = mysql_real_escape_string($_POST["fExperience"]);
$pLocation = $_POST["pLocation"];
$lAbility = $_POST["lAbility"];

$sql = "SELECT * FROM resume";

$string1 = array();
$where1 = "";
if (isset($_POST["aBackground"]) AND !empty($_POST["aBackground"]))
$string1[] = " aBackground LIKE '%".$_POST["aBackground"]."%' ";
if (isset($_POST["fExperience"]) AND !empty($_POST["fExperience"]))
$string1[] = " fExperience LIKE '%".$_POST["fExperience"]."%' ";
if (isset($_POST["pLocation"]) AND !empty($_POST["pLocation"]))
$string1[] = " pLocation LIKE '%".$_POST["pLocation"]."%' ";
if (isset($_POST["lAbility"]) AND !empty($_POST["lAbility"]))
$string1[] = " lAbility LIKE '%".$_POST["lAbility"]."%' ";
if (!empty($string1))
$where1 = " WHERE ".implode("AND", $string1);// OR/AND
$sql1="SELECT * FROM resume $where1";

$string2 = array();
$where2 = "";
if (isset($_POST["aBackground"]) AND !empty($_POST["aBackground"]))
$string2[] = " aBackground LIKE '%".$_POST["aBackground"]."%' ";
if (isset($_POST["fExperience"]) AND !empty($_POST["fExperience"]))
$string2[] = " fExperience LIKE '%".$_POST["fExperience"]."%' ";
if (isset($_POST["pLocation"]) AND !empty($_POST["pLocation"]))
$string2[] = " pLocation LIKE '%".$_POST["pLocation"]."%' ";
if (!empty($string2))
$where2 = " WHERE ".implode("AND", $string2);// OR/AND
$sql2="SELECT * FROM resume $where2";


$string3 = array();
$where3 = "";
if (isset($_POST["aBackground"]) AND !empty($_POST["aBackground"]))
$string3[] = " aBackground LIKE '%".$_POST["aBackground"]."%' ";
if (isset($_POST["fExperience"]) AND !empty($_POST["fExperience"]))
$string3[] = " fExperience LIKE '%".$_POST["fExperience"]."%' ";
if (isset($_POST["lAbility"]) AND !empty($_POST["lAbility"]))
$string3[] = " lAbility LIKE '%".$_POST["lAbility"]."%' ";
if (!empty($string3))
$where3 = " WHERE ".implode("AND", $string3);// OR/AND
$sql3="SELECT * FROM resume $where3";


$string4 = array();
$where4 = "";
if (isset($_POST["aBackground"]) AND !empty($_POST["aBackground"]))
$string4[] = " aBackground LIKE '%".$_POST["aBackground"]."%' ";
if (isset($_POST["pLocation"]) AND !empty($_POST["pLocation"]))
$string4[] = " pLocation LIKE '%".$_POST["pLocation"]."%' ";
if (isset($_POST["lAbility"]) AND !empty($_POST["lAbility"]))
$string4[] = " lAbility LIKE '%".$_POST["lAbility"]."%' ";
if (!empty($string4))
$where4 = " WHERE ".implode("AND", $string4);// OR/AND
$sql4="SELECT * FROM resume $where4";


$string5 = array();
$where5 = "";
if (isset($_POST["fExperience"]) AND !empty($_POST["fExperience"]))
$string5[] = " fExperience LIKE '%".$_POST["fExperience"]."%' ";
if (isset($_POST["pLocation"]) AND !empty($_POST["pLocation"]))
$string5[] = " pLocation LIKE '%".$_POST["pLocation"]."%' ";
if (isset($_POST["lAbility"]) AND !empty($_POST["lAbility"]))
$string5[] = " lAbility LIKE '%".$_POST["lAbility"]."%' ";
if (!empty($string5))
$where5 = " WHERE ".implode("AND", $string5);// OR/AND
$sql5="SELECT * FROM resume $where5";



// Call for this $sql
if ($aBackground== ""&&$fExperience==""&&$pLocation==""&&$lAbility="" ){
$data = mysql_query($sql)
or die("Cannot execute query");
}

elseif(!empty($aBackground)&&!empty($fExperience)& &!empty($pLocation)&&!empty($lAbility)){
$data = mysql_query($sql1)
or die("Cannot execute query");
}


elseif(!empty($aBackground)&&!empty($fExperience)& &!empty($pLocation)){
$data = mysql_query($sql2)
or die("Cannot execute query");
}


elseif(!empty($aBackground)&&!empty($fExperience)& &!empty($lAbility)){
$data = mysql_query($sql3)
or die("Cannot execute query");
}


elseif(!empty($aBackground)&&!empty($pLocation)&&! empty($lAbility)){
$data = mysql_query($sql4)
or die("Cannot execute query");
}


elseif(!empty($fExperience)&&!empty($pLocation)&&! empty($lAbility)){
$data = mysql_query($sql5)
or die("Cannot execute query");
}
?>


<?php
$anymatches = mysql_num_rows($data);
if ($anymatches == 0){

$message="&nbsp;&nbsp;<img src='image/sorry.gif'>".
"<font face='Verdana' size='2'>&nbsp;&nbsp;Sorry, your search returned 0 results.<br>";

include("candidateSearch.php");

exit();
}
?>

<?php
$bgcolor="#ccccff";
?>

<p align=center><center><font face='Verdana' size='3'><strong>Search Results</strong></p>
<table border='1'align=center>
<TABLE width=100% height="43" align=center cellpadding=0 cellspacing=0> <tr>
<td bgcolor='9999ff' >&nbsp;<font face='Verdana' color='#000000' size='3'>Resume ID</font></td>
<td bgcolor='9999ff' >&nbsp;<font face='Verdana' color='#000000' size='3'>Academic Background</font></td>
<td bgcolor='9999ff' >&nbsp;<font face='Verdana' color='#000000' size='3'>Functional Experience</font></td>
<td bgcolor='9999ff' >&nbsp;<font face='Verdana' color='#000000' size='3'>Preferred Location</font></td>
<td bgcolor='9999ff' >&nbsp;<font face='Verdana' color='#000000' size='3'>Languages Ability</font></td></tr>
</tr>


<?php
$counter = 0;
while($result = mysql_fetch_array( $data )){

if ($counter == 3) {

$counter = 0;
}


if($bgcolor=='#ccccff'){$bgcolor='#ffffff';}
else{$bgcolor='#ccccff';}

echo"
<tr><td align=left bgcolor=$bgcolor><a href='candidateSearch_result.php?id={$result['resume_ID']}'>&nbsp;<font face='Verdana' size='2'>{$result['resume_ID']}</a></td>
<td align=left bgcolor=$bgcolor>&nbsp;<font face='Verdana' size='2'>{$result['aBackground']}</td>
<td align=left bgcolor=$bgcolor>&nbsp;<font face='Verdana' size='2'>{$result['fExperience']}</td>
<td align=left bgcolor=$bgcolor>&nbsp;<font face='Verdana' size='2'>{$result['pLocation']}</td>
<td align=left bgcolor=$bgcolor>&nbsp;&nbsp;&nbsp;&nbsp;<font face='Verdana' size='2'>{$result['lAbility']}</td>
</tr>";

$counter = $counter + 1;
}
?>

</table>
<br><br><br><a href='candidateSearch.php? '><font face='Verdana' size='2'>Search again!!</a>


<?
}
?>[/PHP]
Mar 3 '07 #1
Share this Question
Share on Google+
4 Replies


100+
P: 127
I try to edit the code, is already can work...
But still got bug, when i click in the langeanges ability(it is a check box, not list menu, can use the search code as list menu???), it can show any thing and remain in the same page, althrough the data is in the databse...
Could somebody give me a guildeline??
Below is part of my code(for language ability)
Expand|Select|Wrap|Line Numbers
  1.  <tr bgcolor="#A2ABEC"> 
  2.       <td colspan="2"><p align=left><font color="#000000" size="2" face="Verdana">&nbsp;&nbsp;Languages 
  3.           Ability</font></p></td>
  4.     </tr>
  5.     <tr bgcolor="#A2ABEC"> 
  6.       <td height="31"><p align="left">
  7.           <input type="checkbox" name="lAbility" value="english">
  8.           English 
  9.           <input type="checkbox" name="lAbility" value="malay">
  10.           Malay 
  11.           <input type="checkbox" name="lAbility" value="mandarin">
  12.           Mandarin 
  13.           <input type="checkbox" name="lAbility" value="indian">
  14.           Indian </p></td>
  15.       <td></tr>
[PHP]<?php
include("config.php");
if (isset($_POST['aBackground'])) {
$aBackground = mysql_real_escape_string($_POST["aBackground"]);
$fExperience = mysql_real_escape_string($_POST["fExperience"]);
$pLocation = $_POST["pLocation"];
$lAbility = $_POST["lAbility"]
$string1 = array();
$where1 = "";
if (isset($_POST["aBackground"]) AND !empty($_POST["aBackground"]))
$string1[] = " aBackground LIKE '%".$_POST["aBackground"]."%' ";
if (isset($_POST["fExperience"]) AND !empty($_POST["fExperience"]))
$string1[] = " fExperience LIKE '%".$_POST["fExperience"]."%' ";
if (isset($_POST["pLocation"]) AND !empty($_POST["pLocation"]))
$string1[] = " pLocation LIKE '%".$_POST["pLocation"]."%' ";
if (isset($_POST["lAbility"]) AND !empty($_POST["lAbility"]))
$string1[] = " lAbility LIKE '%".$_POST["lAbility"]."%' ";
if (!empty($string1))
$where1 = " WHERE ".implode("AND", $string1);// OR/AND
$sql1="SELECT * FROM resume $where1";
if(!empty($aBackground)&&!empty($fExperience)&&!em pty($pLocation)&&!empty($lAbility)){
$data = mysql_query($sql1)
or die("Cannot execute query");
} [/PHP]
Mar 4 '07 #2

100+
P: 127
i have do a search engine which it search from drop down menu and check box..
im facing problem when using check box as 1 of my search criteria, after i remove it, it can work well..
Can someone give me some guilde??
IS IT DIFFERENT TO CODE THE SEARCH ENGINE FOR DROP DOWN MENU AND CHECK BOX??
HOW SHOULD I CODE FOR THE CHECK BOX ??
Thanks..
Mar 5 '07 #3

ronverdonk
Expert 2.5K+
P: 4,258
Look at the following sample that gets and echoes the content of the checkbox. Caveat: in your code you give each checkbox an identical name. That means that, when someone clicks more than 1 box, you will only get the last one checked in your POST variable! That works like a radio button as far as POST value is concerned.

[php]
<?php
if (isset($_POST['submit'])) {
echo $_POST['lAbility'];
exit;
}
?>
<form method="POST" action="a.php">
<input type="checkbox" name="lAbility" value="english">English
<input type="checkbox" name="lAbility" value="malay">Malay
<input type="checkbox" name="lAbility" value="mandarin">Mandarin
<input type="checkbox" name="lAbility" value="indian">Indian
<input type="submit" name="submit" value="Search" />
</form>[/php]
Ronald :cool:
Mar 5 '07 #4

100+
P: 127
Look at the following sample that gets and echoes the content of the checkbox. Caveat: in your code you give each checkbox an identical name. That means that, when someone clicks more than 1 box, you will only get the last one checked in your POST variable! That works like a radio button as far as POST value is concerned.

[php]
<?php
if (isset($_POST['submit'])) {
echo $_POST['lAbility'];
exit;
}
?>
<form method="POST" action="a.php">
<input type="checkbox" name="lAbility" value="english">English
<input type="checkbox" name="lAbility" value="malay">Malay
<input type="checkbox" name="lAbility" value="mandarin">Mandarin
<input type="checkbox" name="lAbility" value="indian">Indian
<input type="submit" name="submit" value="Search" />
</form>[/php]
Ronald :cool:

I know it will only get the last one checked in POST variable, but i don't know how to change it... I don't want it act like radio button, wat should i change in the code so it can function like checkbox..
And it is same using the code above for search engine in the matter of check box??
Thanks..
Mar 6 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.