Advertisement
Guest User

Untitled

a guest
Sep 27th, 2014
2,778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2. /*
  3.  
  4. This file will pass the countries to the user.
  5.  
  6. */
  7.  
  8. require "dbconnect.php";
  9.  
  10. if(isset($_POST['country'])){
  11.     $country = $_POST['country'];
  12.     if($country != ""){
  13.         $q1 = "SELECT Name FROM Country WHERE Name LIKE :country";
  14.     } else {
  15.         $q1 = "SELECT Name FROM Country";
  16.     }
  17.  
  18.     $pre = $pdo->prepare($q1);
  19.     $pre->bindValue(':country', $country . "%");
  20.  
  21.     if ($pre->execute()) {
  22.         $cnt = $pre->rowCount();
  23.         if($cnt > 0){
  24.             while ($row = $pre->fetch()) {
  25.                 echo "<label class='dataLabel' onclick=\"insertValCountry('". $row['Name'] ."');\">". $row['Name'] ."</label>";
  26.             }
  27.         } else {
  28.             echo "No results found.";
  29.         }
  30.     } else {
  31.         echo "Error in q1";
  32.     }
  33. } else {
  34.     echo "No country received";
  35. }
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement