Advertisement
Guest User

Untitled

a guest
Feb 7th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php
  2. $dsn = 'mysql:hosy=localhost;dbname=products';
  3. $username = 'root';
  4. $password = '';
  5.  
  6. try{
  7. // connect to mysql
  8. $con = new PDO($dsn,$username,$password);
  9. $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  10. } catch (Exception $ex) {
  11. echo 'Not Connected '.$ex->getMessage();
  12. }
  13. $query = $con->prepare("SELECT * FROM store LIMIT 9");
  14. $query->execute();
  15. $items = $query->fetchAll();
  16.  
  17.  
  18. foreach($items as $item) {
  19. echo '
  20. <div class="product">
  21. <div style="height: 7px;visibility: hidden;"></div>
  22. <h3>'.$item["product_name"].'</h3>
  23. <div class="inner">
  24. <div class="image">
  25.  
  26. </div>
  27. </div>
  28. </div>'; }
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement