Shweta
Shweta

Reputation: 807

IF-Else condition in PHP

enter image description hereBased 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>

Upvotes: 0

Views: 81

Answers (3)

Jagdish Barot
Jagdish Barot

Reputation: 201

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 }?>

Upvotes: 0

workthat
workthat

Reputation: 123

In the php code, you put statement echo before you opened the if braces. Also in the if statement, it should be $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}?>

Upvotes: 0

Naresh Kumar
Naresh Kumar

Reputation: 561

Create a field in the database/or the list as appointment status, if a appointment is available then make it true else false. and use it in if else statement

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

Upvotes: 1

Related Questions