Wrox Programmer Forums
|
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2005, 01:35 AM
Registered User
 
Join Date: Jan 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default manipulating data in mysql using php - countries

I am running some querys from my old users profiles and got stuck with one field labelled "country" the data is actually stored as a country number rather than a full alpha word.
When it comes to printing the result i get the country number obviously. So I need to convert these numbers into more meaningful words of each countries.
The following snipit of code I thought would work

Code:
<?php
include_once("countries.php");
?>

<?php
          $countryX = array_flip($country);

          $country_name = 'Yemen';

          if (!$countryX[$country_name]){
               $country_code = 169;
          }
          else {
                $country_code = $countryX[$country_name];
          }
echo ("<td BGCOLOR=#F7BDDE ALIGN=LEFT VALIGN=TOP>Country: ".$country[$country_code]."</td>\n");
?>
The external file would be like this
Code:
 <?php $country = array ("1" => "Afghanistan", "2" => "Albania", "3" => "Algeria", "4" => "Andorra", "5" => "Angola", "6" => "Antigua and arbuda", "7" => "Argentina", "8" => "Armenia", "9" => "Australia",....."Yugoslavia", "166" => "Zaire", "167" => "Zambia", "168" => "Zimbabwe", "169" => "N/A");
?>

At present the country is printing N/A which means not available on on all my users list.

Name: Aditya
Age: 29 Years and 5 Months
************: Male
Country: N/A
Contact

Name: Tristan
Age: 17 Years and 1 Months
************: Male
Country: N/A
Contact

Name: AJ
Age: 21 Years and 11 Months
************: Male
Country: N/A
Contact

Name: Vince
Age: 18 Years and 11 Months
************: Male
Country: N/A
Contact

Some how the script is not displaying the full country.

any ideas?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Php transfering data to mysql Gaurava PHP How-To 2 January 5th, 2008 07:33 AM
manipulating forms with php and javascript Hylsan Beginning PHP 0 April 20th, 2007 09:11 AM
PHP-MySQL Insert Data problem forexen PHP Databases 1 March 13th, 2007 12:58 AM
Storing PHP Session data in a MySQL db? CFerthorney PHP Databases 1 May 10th, 2004 08:33 AM
Editing MySQL data from a PHP form cmiller Beginning PHP 2 September 2nd, 2003 05:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.