...

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



2Pacalypse
03-22-2009, 11:09 PM
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
print ".$location.";
It will say Lounge, rather than if i did

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!

steelaz
03-22-2009, 11:44 PM
You need to create an array:



$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:



$iLocation = 7;

echo $aLocations[$iLocation];



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum