Advertisement
Guest User

Untitled

a guest
Sep 27th, 2014
1,530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.27 KB | None | 0 0
  1. <?php
  2. /*
  3.  
  4. This file will pass all the info we have to the user.
  5.  
  6. */
  7.  
  8. require "dbconnect.php";
  9.  
  10. if(isset($_POST['country']) and isset($_POST['state']) and isset($_POST['city'])){
  11.     $country = $_POST['country'];
  12.     $state = $_POST['state'];
  13.     $city = $_POST['city'];
  14.  
  15.     $html = "";
  16.  
  17.     $q1 = "SELECT * FROM Country WHERE Name = :country";
  18.  
  19.     $pre = $pdo->prepare($q1);
  20.     $pre->bindValue(':country', $country);
  21.  
  22.     if($pre->execute()) {
  23.         $row = $pre->fetch();
  24.  
  25.         $html .= "Country Code: ". $row['Code'] ."<br />";
  26.         $html .= "Country: ". $row['Name'] ."<br />";
  27.         $html .= "State: ". $state ."<br />";
  28.         $html .= "City: ". $city ."<br />";
  29.         $html .= "Continent: ". $row['Continent'] ."<br />";
  30.         $html .= "Region: ". $row['Region'] ."<br />";
  31.         $html .= "Surface Area: ". $row['SurfaceArea'] ."<br />";
  32.         $html .= "Independence Year: ". $row['IndepYear'] ."<br />";
  33.         $html .= "Population: ". $row['Population'] ."<br />";
  34.         $html .= "Life Expectancy: ". $row['LifeExpectancy'] ."<br />";
  35.         $html .= "GNP: ". $row['GNP'] ."<br />";
  36.         $html .= "GNP Old: ". $row['GNPOld'] ."<br />";
  37.         $html .= "Local Country Name: ". $row['LocalName'] ."<br />";
  38.         $html .= "Government Form: ". $row['GovernmentForm'] ."<br />";
  39.         $html .= "Head Of State: ". $row['HeadOfState'] ."<br />";
  40.  
  41.         $q2 = "SELECT Name FROM City WHERE ID = :capital";
  42.  
  43.         $pre2 = $pdo->prepare($q2);
  44.         $pre2->bindValue(':capital', $row['Capital']);
  45.  
  46.         if($pre2->execute()) {
  47.             $row2 = $pre2->fetch();
  48.             $html .= "Capital: ". $row2['Name'] ."<br />";
  49.         } else {
  50.             echo "Error in q2";
  51.             exit;
  52.         }
  53.  
  54.         $html .= "Country Code(2): ". $row['Code2'] ."<br />";
  55.         $html .= "<br />";
  56.         $html .= "Spoken Languages:<br /><br />";
  57.     } else {
  58.         echo "Error in q1";
  59.         exit;
  60.     }
  61.  
  62.     $q3 = "SELECT * FROM CountryLanguage WHERE CountryCode = :code";
  63.  
  64.     $pre3 = $pdo->prepare($q3);
  65.     $pre3->bindValue(':code', $row['Code']);
  66.  
  67.     if($pre3->execute()) {
  68.         while ($row3 = $pre3->fetch()) {
  69.             $html .= "Language: ". $row3['Language'] ."<br />";
  70.             if($row3['IsOfficial'] == "F"){
  71.                 $html .= "Official: No<br />";
  72.             } else {
  73.                 $html .= "Official: Yes<br />";
  74.             }
  75.             $html .= "Percentage of population spoken: ". $row3['Percentage'] ."<br /><br />";
  76.         }
  77.     } else {
  78.         echo "Error in q2";
  79.         exit;
  80.     }
  81.  
  82.     echo $html;
  83. }
  84.  
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement