Guest User

Untitled

a guest
Apr 3rd, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <?php
  2.  
  3. $host = "myHost"; //hidden
  4. $pw = "myPW"; //hidden
  5. $username = "myUser"; //hidden
  6. $dbname = "myDB"; //hidden
  7.  
  8. //phpinfo();
  9.  
  10. $con = mysqli_connect($host, $username, $pw, $dbname);
  11. //echo "<pre>";
  12. //print_r($con);
  13. //echo "</pre>";
  14.  
  15. function fill_brand($con)
  16. {
  17.   $output = '';
  18.   $sql = "SELECT * FROM hersteller";
  19.   $result = mysqli_query($con, $sql);
  20.  
  21.   while ($row = mysqli_fetch_array($result))
  22.   {
  23.     $output .= '<option value="'.$row["brand_id"].'">'.$row["brand_name"].'</option>';
  24.   }
  25.  
  26.   return $output;
  27. }
  28.  
  29.  
  30. function fill_models($con)
  31. {
  32.   $output = '';
  33.   $sql = "SELECT * FROM modelle";
  34.   $result = mysqli_query($con, $sql);
  35.  
  36.   while ($row = mysqli_fetch_array($result))
  37.   {
  38.     $output .= '<div class="col-md-3">';
  39.     $output .= '<div style="border:1px solid #ccc; padding:20px; margin-bottom:20px;">'.$row["model_name"].'';
  40.     $output .= '</div>';
  41.     $output .= '</div>';
  42.   }
  43.   return $output;
  44.  
  45. }
  46.  
  47. ?>
  48.  
  49.  
  50. <div class="container">
  51.   <h3>
  52.     <select name="brand" id="brand">
  53.       <option value ="">Show all Products</option>
  54.       <?php echo fill_brand($con); ?>
  55.     </select>
  56.     <br /><br />
  57.     <div class="row" id="show_model">
  58.       <?php echo fill_models($con);?>
  59.     </div>
  60.   </h3>
  61. </div>
Advertisement
Add Comment
Please, Sign In to add comment