Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    96
    Thanks
    4
    Thanked 0 Times in 0 Posts

    print "$variable"; variable= w/e WHERE "(['db-field'])=$w/e"

    Hello everyone!

    I have a slight problem!

    Here's a example:
    First is something like a user field
    Second is a list of locations and the numbers they relate to in the uer fields

    User:
    blah=blah
    blah=blah
    location=7

    location_name:
    1=Kitchen
    2=Hall
    3=School
    4=blah
    5=blah
    6=bathroom
    7= Lounge



    So in this case if the "location=7" and "7=Lounge"
    Then if i
    PHP Code:
    print ".$location."
    It will say Lounge, rather than if i did
    PHP Code:
    print "['location']"
    Which would probably give me suntax error, but perhaps it would show "7" as the original value.

    Can anyone help with a few lines to "convert" from the example of "7" to "Lounge"?

    Please and thanks!

  • #2
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    You need to create an array:

    PHP Code:
    $aLocations = array();

    $aLocations[1] = 'Kitchen';
    $aLocations[2] = 'Hall';
    $aLocations[3] = 'School';
    $aLocations[4] = 'blah';
    $aLocations[5] = 'blah';
    $aLocations[6] = 'bathroom';
    $aLocations[7] = 'Lounge'
    Then you can access array member by its index:

    PHP Code:
    $iLocation 7;

    echo 
    $aLocations[$iLocation]; 


  •  

    Posting Permissions

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