leest Posted January 31, 2008 Share Posted January 31, 2008 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 } Quote Link to comment https://forums.phpfreaks.com/topic/88746-solved-php-if-else-problem/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.