|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Printing Country name instead of Code
Hey all. I am still having problems with this. This is the last of my problems for this script
. I found ways to get around everything else :-D. Ok, what I am trying to do is print the country name instead of the country value. There are two tables. One is called users, the other is called countried. In the user table,it stores the country code in this format (CA,JM,GB,US,AL etc). In the countries table it is stored as column 0 (name) is the country code and column 1 (value) is the country name. I would like it to print out the country name from the country codes in the Users table. Someone suggested to use a table join, but I tried it and it didnt work. I think it didnt work because of the way the country codes are stored in the Users table. here is the code.PHP Code:
The if statement that tests whether $value == CA or $value == JM dont work. It will only print out Canada if that is the case. It wont ever print out the second country (or any other country but Canada). Thanks for the help |
|
#2
|
|||
|
|||
|
try replacing this
if ($value == CA){ echo "Canada";} else if ($value == JM){ with this if ($value == "CA"){ echo "Canada";} else if ($value == "JM"){ all ive done is placed "" around the value words. that should work now |
|
#3
|
|||
|
|||
|
I tried that yesterday and it didnt work. I dont understand. Can someone perhaps tell me if $value is a string or an array?
Patrick |
|
#4
|
|||
|
|||
|
your made a big booboo!
your trying to call a variable that doesnt exist $myrow????? try changing any instances of $myrow with $b |
|
#5
|
|||
|
|||
|
Just a friendly suggestion:
You should give your variables better names (not $a, $b, $c, etc).. Making sensible variable names will increase the code readability (which I think is very important)
__________________
Best Regards, Håvard Lindset Last edited by Lindset : July 24th, 2002 at 10:53 PM. |
|
#6
|
|||
|
|||
|
My fault in the copy/paste
![]() PHP Code:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Printing Country name instead of Code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|