Advertisement
Guest User

Untitled

a guest
Nov 26th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. function db_connect(){
  4. $host = 'localhost';
  5. $user = 'tolik';
  6. $pass = '1234';
  7. $db = 'collection';
  8.  
  9. $connection = mysqli_connect($host, $user, $pass, $db);
  10. // $db_select =
  11. if (!$connection){
  12. return false;
  13. }
  14. return $connection;
  15. }
  16.  
  17. function db_result_to_array($result){
  18. $res_array = array();
  19. $count = 0;
  20. while ($row = mysqli_fetch_array($result)){
  21. $res_array[$count] = $row;
  22. $count++;
  23. }
  24. return $res_array;
  25. }
  26.  
  27. function get_products(){
  28.  
  29. db_connect();
  30.  
  31. $query = "SELECT * FROM clothes ORDER BY id DESC";
  32.  
  33. $result = mysqli_query($query);
  34.  
  35. $result = db_result_to_array($result);
  36.  
  37. return $result;
  38. }
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement