Results 1 to 4 of 4

Thread: either : or command to an if/else?

  1. #1
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default either : or command to an if/else?

    I have some lines in a php script that controls the location of images (in this case smileys). Right now there are 2 options the post form and the pop up window.

    Okay, so what I want to do is add more pop up windows to store more and different smileys in them.

    Currently, one such line looks like this:

    PHP Code:
    $location = empty($row['hidden']) ? 'postform' 'popup'
    Obviously this defines the location var. and as you can see there are only 2 options 'postform' and 'popup' this is evident by the *:* yes?

    So I need a way to rewrite this (and the other lines) so I can include 'popup_a', 'popup_b' etc. I have a total of 8 pop ups, (including the original) that need to be included.

    Perhaps a nested if/else statement? I am just not sure how to write this out.

    I then will need to add something to the MySQL database to accept the different locations wont I? right now it has 3 options 0, 1 and 2 where 0 is the 'postform' and the 2 is the 'popup' and the 1 means hidden.

    What would I need to edit there to include 3 - 9 where 3 = 'popup_a' and so on. to 9 = 'popup_g'

    Advise? Thanks!
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    Well, remember that parentheses are your friend in the case of trying to write something on one line.
    You could write something like:

    cond1 ? cond2 : (cond3 ? cond4 : (...));

    ...or something like that...
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    I think I understand what you mean. I will give it a go in a couple days when I can find some time (just started a new job last week and am playing catch up )

    Thanks for the idea, I will let you know what shakes.
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    There are other options.... that was just a quick thought.
    However, using words is helpful for reading it.
    If makes more sense than ?... most of the time.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •