简体   繁体   English

PHP中的IF-Else条件

[英]IF-Else condition in PHP

在此处输入图片说明 Based on the status which displays whether appointment is available or unavailable. 基于显示约会是否可用的状态。 I want to display if the status is available the user will redirected through a link to new page and if appointment is unavailable the status will be hidden. 我想显示状态是否可用,用户将通过链接重定向到新页面,如果约会不可用,状态将被隐藏。 Not sure where I am going wrong.. 不知道我要去哪里错了..

</thead>
          <tbody>
          <?php
          if(is_array($appointmentdetails) || isset($displayAppointment)){
          foreach($appointmentdetails as $displayAppointment) { ?> 


          <tr>

            <td><?php print $displayAppointment['DOCTOR_LICENSE_NO']; ?></td>
            <td><?php print $displayAppointment['DOCTOR_FNAME']; ?></td>
            <td><?php print $displayAppointment['DOCTOR_LNAME']; ?></td>
            <td><?php print $displayAppointment['DOCTOR_EMAIL_ID']; ?></td>
            <td><?php print $displayAppointment['DOCTOR_PHONE']; ?></td>
            <td><?php print $displayAppointment['APPOINTMENT_DATE']; ?></td>
            <td><?php print $displayAppointment['APPOINTMENT_TIME']; ?></td>


   --> Here I want to display the given condition 

   <?php if($displayAppointment['APPOINTMENT_STATUS']=="Available")

                        { ?>    
                            <td><a href="input_user.php?APPOINTMENT_STATUS=<?php print $displayAppointment['APPOINTMENT_STATUS']; ?>"><?php print $displayAppointment['APPOINTMENT_STATUS']; ?></a></td>
                        <?php } 
                         else ?>
                        <?php {?>
                            <td><?php print $displayAppointment['APPOINTMENT_STATUS']; ?></td>
                        <?php}?>

      </tr>
      <?php } } ?>
                        </tbody>
      </table>

        </body>

Create a field in the database/or the list as appointment status, if a appointment is available then make it true else false. 在数据库/或列表中创建一个字段作为约会状态,如果有约会可用,则将其设置为true,否则为false。 and use it in if else statement 并在if else语句中使用它

if($displayAppointment['APPOINTMENT_STATUS'])
{
   echo "Appointment available" ; //or what ever your link
}
else
{
   echo "redirect";
}

In the php code, you put statement echo before you opened the if braces. 在php代码中,您在打开if括号之前放入了echo语句。 Also in the if statement, it should be $displayAppointment['APPOINTMENT_STATUS'] 同样在if语句中,它应该是$ displayAppointment ['APPOINTMENT_STATUS']

<?php if($displayAppointment['APPOINTMENT_STATUS']=="Available")
   { 
  //put echo here
    echo 'APPOINTMENT_STATUS'; ?>
    <td><a href="input_user.php?APPOINTMENT_STATUS=<?php print $displayAppointment['APPOINTMENT_STATUS']; ?>"><?php print $displayAppointment['APPOINTMENT_STATUS']; ?></a></td>
     <?php } 
     else {?>
         <td> <input type="hidden" name="APPOINTMENT_STATUS" value="<?php print $displayAppointment['APPOINTMENT_STATUS'];?>" ></td>
     <?php}?>
This is Youre Code :
<td><?php print $displayAppointment['APPOINTMENT_STATUS']; ?></td>
                            <?php}?>

Need space after <?php 
Right Code :

 <td><?php print $displayAppointment['APPOINTMENT_STATUS']; ?></td>
                        <?php }?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM