lundi 30 mai 2016

(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.

<?php
include('DBconnect.php');
mysql_query("USE onlinerecruitment");

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

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

?>

<table style="width:100%">
<tr>

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

</tr>

<?php
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;

    }

}

?>
</table>

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.

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

Aucun commentaire:

Enregistrer un commentaire