Jump to content

[SOLVED] Php If Else Problem


leest

Recommended Posts

OK, i hav had this problem for a while i try and fix it then leave it and come back to later on when i have some spare time, but i just keep confusing myself with the more and more tutorials and things i read.

 

Below is my if else script, that is for a job site that i am putting together,

 

The first part checks to see if a candidate has already applied for this position previously, first it gets the candidate id if there is one and then checks it against the database to see if it already exsists for that job.

 

This all works perectly and to be honest some body helped me achieve the last part with the if num bit.

 

now in the else part i know that the candidate has already applied for that job and so i wanted to check to see if they have already applied to this company by checking the site id.  If they have i want to just add them to this job, but if they haven't i want to insert them in to the company and for this job.

 

now the problem i am having is that the first query of this part also uses the if num and i do not understand how to format this as it will not allow me to add another else or if i try else if, it doesn't work at all.

 

Any guidance would be appreciated.

 

Thanks

lee

 

//*** Checks the database to see if the Candidate already exsist in this companies system *****//
    include '../System/connections/db1.php';
    $username = $_SESSION['username'];
    $SID = $_SESSION['SID'];

     //***** Gets Candidate ID from candidate table  *************//
    $query = "SELECT * FROM candidate WHERE username ='$username' AND site_id ='$SID'"; 	 
    $result = mysql_query($query) or die(mysql_error());
    $row = mysql_fetch_array($result) or die(mysql_error());
    $candidate_id = $row['candidate_id'];  

    $candidate_id = $row['candidate_id']; 
$JOID = $_SESSION['JOID'];
$query = "SELECT * FROM candidate_joborder WHERE candidate_id ='$candidate_id' AND joborder_id = '$JOID'";
    $result = mysql_query($query)or die(mysql_error());
    $num = mysql_num_rows($result); //will be either 0 if its not there or more than zero if it is
    if ($num > 0){ 

$CJID = $_SESSION['CJID'];
    echo "You have already Applied for this Vacancy, to monitor the status of this Application please visit the My Applications page of your account, the reference number for this vacancy is: $CJID";}

  else{
  
  $query = "SELECT username FROM candidate WHERE username ='$username' AND site_id ='$SID'";
  $result = mysql_query($query)or die(mysql_error());
  $num = mysql_num_rows($result); //will be either 0 if its not there or more than zero if it is
  if($num > 0) { //checks for an entry
  
   }

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.