dongyoulou4829 2016-05-30 11:47
浏览 224
已采纳

(PHP)IF-ELSE同时有两个条件

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 as the last one.

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

  • 写回答

1条回答 默认 最新

  • dongtiao0279 2016-05-30 12:07
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog