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 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作