Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End if else statement help

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #44177
    kpearson
    Member

    Hi, Im new to php so I’m having a small problem with if statments

    basically I want an out put to be if its less that 18 to show less than 18 message, if its more than 23 then show its more than 23 message and if its a range between 18 and 23 to say a mid range message. I can get it to output corectly for more than 23 and less than 18 but I cant get it to output for anything between 18 and 23.

    can any one help please

    (http://codepen.io/anon/pen/qdKyp “code on codepen”)http://codepen.io/anon/pen/qdKyp[code is here](http://codepen.io/anon/pen/qdKyp “code on codepen”)http://codepen.io/anon/pen/qdKyp

    #132095
    CrocoDillon
    Participant

    if ($result < 18) {
    // less than 18
    } elseif ($result > 23) {
    // more than 23
    } else {
    // between 18 and 23
    }

    #132097
    kpearson
    Member

    when i change the last elseif to else the page dosent display

    #132098
    CrocoDillon
    Participant

    You have

    23 or $resultB = range(18,23)): ?>

    23): ?>

    if you change the last elseif to `` it doesn’t work?

    #132099
    CrocoDillon
    Participant

    You might as well remove the outer if by the way, it does nothing.

    #132101
    kpearson
    Member

    23 or $resultB = range(18,23)): ?>

    Wellbeing

    23): ?>



    yep thats what I have and I changed to:

    23 or $resultB = range(18,23)): ?>

    Wellbeing

    23): ?>



    #132103
    kpearson
    Member

    if change to else then page does not load.

    #132104
    CrocoDillon
    Participant

    should be

    #132115
    kpearson
    Member

    All working now, thank you for your help :) learned alot there…. also removed outer if statement cheers

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Back End’ is closed to new topics and replies.