Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. $query = tep_db_query("SELECT countries_name, countries_id FROM " . TABLE_COUNTRIES);
  2.  
  3. $countries = array();
  4.  
  5. while($row = tep_db_fetch_array($query))
  6. {
  7.     $countries[$row['countries_id']] = $row['countries_name'];
  8. }
  9.  
  10. ///////////////////////////////////////////////////////////////////////////////////
  11. $country_name = "Africa";
  12. $country_id = NULL;
  13.  
  14. foreach($countries as $id => $name)
  15. {
  16.         if($country_name == $name)
  17.     {
  18.         $country_id = $id;
  19.         break;
  20.     }
  21. }
  22.  
  23. if($country_id != NULL)
  24. {
  25.     echo $country_name . ' has an ID of ' . $country_id;
  26. {
  27. else
  28. {
  29.     echo 'Could not find an ID of ' . $country_name . ' because it does not exist';
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement