SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: selec Selected

  1. #1
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    selec Selected

    I'm having trouble in showing the value of my selected value in select dropdown.

    Code:
    $stat = $data['ba_Status'];	
    
    
    <select>
        <option value="January"<?php if (($stat == '0') || ($stat == 'R') || ($stat == 'D') || ($stat == 'S1') || ($stat == 'F1')) echo ' selected="selected"'; ?>>YES</option>
        <option value="December"<?php if ($stat == 'L') echo ' selected="selected"'; ?>>NO</option>
    </select>
    I tried else statement, but it an error occured.

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Check the output of var_dump($stat) and check for that exact output, especially that =='0', does it output what you think?

    nb wouldn't it be easier just to check if $stat is L?


Bookmarks

Posting Permissions

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