General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 23rd, 2002, 08:45 AM
hereford hereford is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 11 hereford User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to hereford
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:
 $a mysql_query("SELECT Country_Visited FROM neighbors_1 WHERE E_mail = '$email'");
    while(
$b mysql_fetch_array($a)){
        
$c explode(","$b[0]);
        
$d mysql_query("select Country_Visited from neighbors_1 WHERE E_mail='$myrow[3]'");
        while(
$e mysql_fetch_array($d)){
            
$f explode(","$e[0]);
            foreach (
$f as $value){
                if (
in_array($value$c)){
                        print(
"<tr><td bgcolor='$bg'><font size='2'>&nbsp;");
                       
printf("<a href=\"personal.php?Customer_ID=%s\"> %s %s</a></font>"$myrow[0],$myrow[1],$myrow[2]);
                         print(
"</td><td bgcolor='$bg'><font size='2'>");
                        
printf("<a href=\"mailto:%s\">%s"$myrow[3],$myrow[3]);
                        print(
"</a></font></td>");
                        
printf("<td bgcolor='$bg'><font size='2'>");
                     echo 
$value;
                     if (
$value == CA){
                         echo 
"Canada";}
                     else if (
$value == JM){
                         echo 
"Jamaica";}
                        print(
"&nbsp;</font></td>");
                        print(
"<td bgcolor='$bg'><font size='2'>&nbsp;");
                        
printf("%s",$myrow[10]);
                        print(
"</font></td>");

                    }
                }
            }
        } 


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

Reply With Quote
  #2  
Old July 23rd, 2002, 06:26 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #3  
Old July 24th, 2002, 10:34 AM
hereford hereford is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 11 hereford User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to hereford
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

Reply With Quote
  #4  
Old July 24th, 2002, 06:40 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
your made a big booboo!

your trying to call a variable that doesnt exist

$myrow?????

try changing any instances of $myrow with $b

Reply With Quote
  #5  
Old July 24th, 2002, 10:41 PM
Lindset Lindset is offline
weirdomoderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Alta, Norway
Posts: 370 Lindset User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Lindset Send a message via AIM to Lindset
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.

Reply With Quote
  #6  
Old July 25th, 2002, 08:26 AM
hereford hereford is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 11 hereford User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to hereford
My fault in the copy/paste
PHP Code:
 $myrowmysql_fetch_row($result);
$email $myrow[3];
$result mysql_query("SELECQT * FROM neighbors_1 WHERE E_mail = $email"); 

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Printing Country name instead of Code


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT