gznero gznero - 4 months ago 5x
MySQL Question

(PHP) IF-ELSE two conditions at once

I'm new to PHP, now I have some problems in IF-ELSE conditions

These are my codes so far.

mysql_query("USE onlinerecruitment");

$app_id_check = "";
$app_pos_check = "";

$result = mysql_query("SELECT * FROM applicant_skill ");


<table style="width:100%">

<th>Applicant's Name</th>
<th>Last Name</th>
<th>Position Selected</th>


while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){

$check_app_id = $row['App_Data_ID'];
$check_pos_id = $row['Position_ID'];

if($app_id_check != $check_app_id && $app_pos_check != $check_pos_id){

$skill_id = $row['Skill_ID'];
$app_id = $row['App_Data_ID'];

$result01 =mysql_query("SELECT * FROM required_skills WHERE Skill_ID = '".$skill_id."' ");
$row01 = mysql_fetch_array($result01, MYSQL_ASSOC);

$skill_name = $row01['Skill_Name'];
$pos_id = $row01['Position_ID'];

$result02 = mysql_query("SELECT * FROM position WHERE Position_ID = '".$pos_id."' ");
$row02 = mysql_fetch_array($result02, MYSQL_ASSOC);

$result1 = mysql_query("SELECT * FROM application_data_file WHERE App_Data_ID = '".$app_id."' ");
$row1 = mysql_fetch_array($result1, MYSQL_ASSOC);

$app_mail = $row1['App_Email'];

$result2 = mysql_query("SELECT * FROM applicant_acct WHERE App_Email = '".$app_mail."' ");
$row2 = mysql_fetch_array($result2, MYSQL_ASSOC);

echo "<TR>";

echo "<TD>".$row2['App_Name']."</TD>";
echo "<TD>".$row2['App_LName']."</TD>";
echo "<TD>".$row02['Position_Name']."</TD>";
echo "<TD><a href='edit-testing-score-form.php?app_id=".$row['App_Data_ID']."&pos_id=".$row['Position_ID']."'>Edit Testing Score</a></TD>";
echo "<TD><a onclick='javascript:confirmationDelete($(this));return false;' href='delete-testing-score.php?app_id=".$row['App_Data_ID']."&pos_id=".$row['Position_ID']."'>Delete</a></TD>";

echo "</TR>";

$app_id_check = $app_id;
$app_pos_check = $pos_id;




This is my result so far

enter image description here

And this is my data in the database

enter image description here

According to my image of my database, the result should not be 2 rows in the table like in the first table. It now prints out only App_Data_ID 00001 and 00012 only which because they are first one who has not the same Position_ID.

My intended result, the table should print App_Data_ID 00001,00002,00012,00013,00014 and so on. It should not print when only App_Data_ID and Position_ID are exactly the same as the last one.

I think my logic in IF-ELSE condition is some kind wrong but I don't know why, Please help.


Do one thing.
Change the SQL from SELECT * FROM applicant_skill to SELECT * FROM applicant_skill where App_Data_ID<>Position_ID. By this you no need to check with if else. It will only display those data where App_Data_ID and Position_ID are not same.
I thing this will solve your problem.