SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question if statement problems

    I'm trying to get an if statement to work in the following way.
    I need the script to realise if value is between say 1 and 2 and return a checked radio button.
    I can get the radio button to be check if the value equals 1 using the code below

    <?php if($average_communication_rating == '1'){ echo 'checked="checked"';} ?>

    I can't get it to work if the value is between 1 and 2, I was trying to use the following but I keep getting these errors

    <?php if($average_communication_rating => '1' AND < '2'){ echo 'checked="checked"';} ?>


    I think this is something that should be ffairly easy to sort out but I can't seem to fix it at all.

    Any help would be much appreciated.

    Thanks

  2. #2
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the syntax is >=
    my mobile portal
    ghiris.ro

  3. #3
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    62 Post(s)
    Tagged
    0 Thread(s)

    <?php if($average_communication_rating >= '1' AND $average_communication_rating <= '2'){ echo 'checked="checked"';} ?>


    (Note: the checkbox will be checked if the value is 2.)
    Salathe
    Software Developer and PHP Manual Author.

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the logic operators always have the > or < first >=, <=

  5. #5
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great thanks for sorting this out for me!


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
  •