www.webdeveloper.com
Results 1 to 2 of 2

Thread: I can't get my else statement to work.. i know i have a syntax error as well..

  1. #1
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    Cool I can't get my else statement to work.. i know i have a syntax error as well..

    If there is no image it returns No Rx on File, this works fine. If there is an image it returns Rx Requires Validation in a blue link. When an image is uploaded it's a 0, when it's selected as active it becomes a 1 as the active field in the database. I'm not sure how to have all images as 0 blue and now the active images that are 1 green. I thought my logic is quite busted at this point.. any help would be greatly appreciated.

    Help please.


    PHP Code:
    if ($a['rx_scanned'] === null)
        {
             echo 
    "<tr><td>**No Rx on File**</td></tr>"
        }

        
    elseif (
    $a['rx_scanned'] = 
        {
      
    $rx_image_color '#009933';
      
          echo 
    "<tr><td> &nbsp;<img src='http://sqlserver/test/tim/leaflet/check-icon.gif'>&nbsp;<a href='" 
                
    matry::base_to('patient/image/view', array('event_id'=>$event->id'patient_id'=>$patient->code'uniqueid'=>$a['image_id'])) 
                . 
    "' style='color:$rx_image_color'>Valid Rx on File</a></td></tr>"

        }
    else  (
    $a['rx_scanned'] = 0)
        { 
          
    $rx_image_color '#3366FF';
          echo 
    "<tr><td>" cbox_return($name) . "<a href='" 
                
    matry::base_to('patient/image/view', array('event_id'=>$event->id'patient_id'=>$patient->code'uniqueid'=>$a['image_id'])) 
                . 
    "'>**Rx Requires Validation**</a></td></tr>"
        } 

    This was my original else statement with no syntax errors:

    PHP Code:
    else   
        { 
          
    $rx_image_color '#3366FF';
          echo 
    "<tr><td>" cbox_return($name) . "<a href='" 
                
    matry::base_to('patient/image/view', array('event_id'=>$event->id'patient_id'=>$patient->code'uniqueid'=>$a['image_id'])) 
                . 
    "'>**Rx Requires Validation**</a></td></tr>"
        }   

    echo 
    "<tr><td></td></tr>"
    Although it didn't ever get to the else statement and it never functioned properly.

  2. #2
    Join Date
    Feb 2013
    Posts
    2
    The problem is about:
    PHP Code:
    else  ($a['rx_scanned'] = 0
    As You need to use else if whenever You define conditions, and using else must be without conditions.
    Also, You've to use comparison operators like: == not assignment operators like =

    So, You can do:
    PHP Code:
    elseif  ($a['rx_scanned'] == 0

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles