Guest User

Untitled

a guest
Jul 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <?php
  2.  
  3. require_once('classes/db.php');
  4. require_once('classes/post.php');
  5.  
  6. $db = new database('localhost', 'xx', 'yy');
  7. $db->connect();
  8. $db->selectDB('xx');
  9.  
  10. $posts = array();
  11.  
  12. function loadPosts(){
  13.     $result = mysql_query("SELECT * FROM posts") or die ("Could not get data: ".mysql_error());
  14.    
  15.     while($row = mysql_fetch_array($result)){
  16.         $posts[] = new post($row['headline'], $row['body'], $row['date']);
  17.     }
  18.     // Size of posts -> 1
  19. }
  20.  
  21. // Size of posts -> 0 dafuck?
  22.  
  23. function listPosts(){
  24.     for($i = 0; $i <= sizeof($posts); $i++){
  25.         $posts[$i]->printPost();
  26.     }
  27. }
  28.  
  29. ?>
Add Comment
Please, Sign In to add comment