candidate search, blanks page, problem...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bb nicole
    New Member
    • Jan 2007
    • 127

    candidate search, blanks page, problem...

    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_esca pe_string($_POS T["aBackgroun d"]);
    $fExperience = mysql_real_esca pe_string($_POS T["fExperienc e"]);
    $pLocation = $_POST["pLocation"];
    $lAbility = $_POST["lAbility"];

    $sql = "SELECT * FROM resume";

    $string1 = array();
    $where1 = "";
    if (isset($_POST["aBackgroun d"]) AND !empty($_POST["aBackgroun d"]))
    $string1[] = " aBackground LIKE '%".$_POST["aBackgroun d"]."%' ";
    if (isset($_POST["fExperienc e"]) AND !empty($_POST["fExperienc e"]))
    $string1[] = " fExperience LIKE '%".$_POST["fExperienc e"]."%' ";
    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($string 1))
    $where1 = " WHERE ".implode("AND" , $string1);// OR/AND
    $sql1="SELECT * FROM resume $where1";

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


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


    $string4 = array();
    $where4 = "";
    if (isset($_POST["aBackgroun d"]) AND !empty($_POST["aBackgroun d"]))
    $string4[] = " aBackground LIKE '%".$_POST["aBackgroun d"]."%' ";
    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($string 4))
    $where4 = " WHERE ".implode("AND" , $string4);// OR/AND
    $sql4="SELECT * FROM resume $where4";


    $string5 = array();
    $where5 = "";
    if (isset($_POST["fExperienc e"]) AND !empty($_POST["fExperienc e"]))
    $string5[] = " fExperience LIKE '%".$_POST["fExperienc e"]."%' ";
    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($string 5))
    $where5 = " WHERE ".implode("AND" , $string5);// OR/AND
    $sql5="SELECT * FROM resume $where5";



    // Call for this $sql
    if ($aBackground== ""&&$fExperienc e==""&&$pLocati on==""&&$lAbili ty=""){
    $data = mysql_query($sq l)
    or die("Cannot execute query");
    }

    elseif(!empty($ aBackground)&&! empty($fExperie nce)&&!empty($p Location)&&!emp ty($lAbility)){
    $data = mysql_query($sq l1)
    or die("Cannot execute query");
    }


    elseif(!empty($ aBackground)&&! empty($fExperie nce)&&!empty($p Location)){
    $data = mysql_query($sq l2)
    or die("Cannot execute query");
    }


    elseif(!empty($ aBackground)&&! empty($fExperie nce)&&!empty($l Ability)){
    $data = mysql_query($sq l3)
    or die("Cannot execute query");
    }


    elseif(!empty($ aBackground)&&! empty($pLocatio n)&&!empty($lAb ility)){
    $data = mysql_query($sq l4)
    or die("Cannot execute query");
    }


    elseif(!empty($ fExperience)&&! empty($pLocatio n)&&!empty($lAb ility)){
    $data = mysql_query($sq l5)
    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("candid ateSearch.php") ;

    exit();
    }
    ?>

    <?php
    $bgcolor="#cccc ff";
    ?>

    <p align=center><c enter><font face='Verdana' size='3'><stron g>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'>Academ ic Background</font></td>
    <td bgcolor='9999ff ' >&nbsp;<font face='Verdana' color='#000000' size='3'>Functi onal Experience</font></td>
    <td bgcolor='9999ff ' >&nbsp;<font face='Verdana' color='#000000' size='3'>Prefer red Location</font></td>
    <td bgcolor='9999ff ' >&nbsp;<font face='Verdana' color='#000000' size='3'>Langua ges Ability</font></td></tr>
    </tr>


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

    if ($counter == 3) {

    $counter = 0;
    }


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

    echo"
    <tr><td align=left bgcolor=$bgcolo r><a href='candidate Search_result.p hp?id={$result['resume_ID']}'>&nbsp;<font face='Verdana' size='2'>{$resu lt['resume_ID']}</a></td>
    <td align=left bgcolor=$bgcolo r>&nbsp;<font face='Verdana' size='2'>{$resu lt['aBackground']}</td>
    <td align=left bgcolor=$bgcolo r>&nbsp;<font face='Verdana' size='2'>{$resu lt['fExperience']}</td>
    <td align=left bgcolor=$bgcolo r>&nbsp;<font face='Verdana' size='2'>{$resu lt['pLocation']}</td>
    <td align=left bgcolor=$bgcolo r>&nbsp;&nbsp;& nbsp;&nbsp;<fon t face='Verdana' size='2'>{$resu lt['lAbility']}</td>
    </tr>";

    $counter = $counter + 1;
    }
    ?>

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


    <?
    }
    ?>[/PHP]
  • bb nicole
    New Member
    • Jan 2007
    • 127

    #2
    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)
    Code:
     <tr bgcolor="#A2ABEC"> 
          <td colspan="2"><p align=left><font color="#000000" size="2" face="Verdana">&nbsp;&nbsp;Languages 
              Ability</font></p></td>
        </tr>
        <tr bgcolor="#A2ABEC"> 
          <td height="31"><p align="left">
              <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 </p></td>
          <td></tr>
    [PHP]<?php
    include("config .php");
    if (isset($_POST['aBackground'])) {
    $aBackground = mysql_real_esca pe_string($_POS T["aBackgroun d"]);
    $fExperience = mysql_real_esca pe_string($_POS T["fExperienc e"]);
    $pLocation = $_POST["pLocation"];
    $lAbility = $_POST["lAbility"]
    $string1 = array();
    $where1 = "";
    if (isset($_POST["aBackgroun d"]) AND !empty($_POST["aBackgroun d"]))
    $string1[] = " aBackground LIKE '%".$_POST["aBackgroun d"]."%' ";
    if (isset($_POST["fExperienc e"]) AND !empty($_POST["fExperienc e"]))
    $string1[] = " fExperience LIKE '%".$_POST["fExperienc e"]."%' ";
    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($string 1))
    $where1 = " WHERE ".implode("AND" , $string1);// OR/AND
    $sql1="SELECT * FROM resume $where1";
    if(!empty($aBac kground)&&!empt y($fExperience) &&!empty($pLoca tion)&&!empty($ lAbility)){
    $data = mysql_query($sq l1)
    or die("Cannot execute query");
    } [/PHP]

    Comment

    • bb nicole
      New Member
      • Jan 2007
      • 127

      #3
      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..

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        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">M alay
        <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:

        Comment

        • bb nicole
          New Member
          • Jan 2007
          • 127

          #5
          Originally posted by ronverdonk
          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">M alay
          <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..

          Comment

          Working...