SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old August 28th, 2002, 09:06 AM
mandy mandy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 mandy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
viewing data problem

i have two tables as below:

table USER(
id char(10)
name char(20)
email char(20)
country char(20)
);

table COUNTRY(
country_id char(20),
country_name char(20)
);

the country_id is store into the USER table as it selected

so next, i want to view my data,

<?
mysql_connect("localhost", "root");
@mysql_select_db("user") ;
$result = mysql_query("select * from user");
$row = mysql_fetch_array($result);
?>
echo "Name: ".$myrow["name"];
echo "email: ".$myrow["email"];
echo "country: ".$myrow["country"];

that's the problem, it show the country_id not the country_name, so how i query from them to view the country field is country name

Reply With Quote
  #2  
Old August 28th, 2002, 11:16 AM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: viewing data problem

Change the code on the mysql_query line to something like :
php Code:
Original - php Code
  1. <?
  2. $result = mysql_query("select user.*, country.country_name from user, country WHERE country.country_id=user.country");
  3. ?>

It's probably a good idea to change the user.country and country.country_id fields to be integers.. faster lookup.

Hope this helps

Reply With Quote
  #3  
Old August 28th, 2002, 12:08 PM
mandy mandy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 mandy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: viewing data problem

ha..ha...thanks CmdrDats ur help.....it worked now....thanks

Reply With Quote
  #4  
Old August 28th, 2002, 01:23 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: viewing data problem

only a pleasure to be of assistance ;)

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > viewing data problem


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 3 hosted by Hostway