PHP if-else condition in JSON to change the event color in fullcalendar -


<?php header("access-control-allow-origin: *"); header('content-type:application/json');  mysql_connect('localhost','root','') or die(mysql_error());  mysql_select_db('pmothesis');  $select = mysql_query("select * venue_reservations join venue on venue.venue_code = venue_reservations.venue_code join office on office.office_id = venue_reservations.office_id status != 'finished'");  $rows = array();  while ($row = mysql_fetch_array($select)) {     $rows[] = array('id'=>$row['venue_reservation_id'],                     'title'=>$row['venue_name'],                     'start'=>$row['date_time_start'],                     'end'=>$row['date_time_end'],                     'description'=>"purpose: ".$row['purpose'].                     ' <br> venue reservation id: ' .$row['venue_reservation_id'].                     ' <br> event type: ' .$row['event_type'].                     ' <br> number of persons: ' .$row['number_of_persons'].                     ' <br> office name: ' .$row['office_name'].                     ' <br> <br> status: <font style="color: red;"> ' .$row['status']. ' </font>'                     ); }    echo json_encode($rows); ?> 

that json file. want change event color of fullcalendar. have conditions related reservation approval. example, if it's approved, event change color blue red pending. answers highly appreciated. thank :)

as suggested @marcb, need if , $color :

while ($row = mysql_fetch_array($select)) {   if ( $row['status'] == "approved" )     //<========= check status here.          $color = "blue";     else $color = "red";     $rows[] = array('id'=>$row['venue_reservation_id'],                     'title'=>$row['venue_name'],                     'start'=>$row['date_time_start'],                     'end'=>$row['date_time_end'],                     'description'=>"purpose: ".$row['purpose'].                     ' <br> venue reservation id: ' .$row['venue_reservation_id'].                     ' <br> event type: ' .$row['event_type'].                     ' <br> number of persons: ' .$row['number_of_persons'].                     ' <br> office name: ' .$row['office_name'].                     ' <br> <br> status: <font style="color: ' . $color . ';"> ' . //<========= color variable.                     $row['status']. ' </font>'                     ); } 

as have read in comments, it's time stop using mysql , change mysqli (or pdo) , start using css classes.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -