Posted By

JonnySnip3r on 11/03/10


Tagged

archive create functionoop


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Desoxena


Create Archive Function


 / Published in: PHP
 

This has been updated, fully working now

  1. public function create_archive()
  2. {
  3. // Loop through the database grabbing all the dates::
  4. // $sql = "SELECT DISTINCT blog_date FROM subarc_blog ORDER BY blog_date";
  5. $sql = "SELECT DISTINCT MONTHNAME(blog_date) as blog_month, YEAR(blog_date) as blog_year FROM subarc_blog ORDER BY blog_date";
  6.  
  7. $stmt = $this->conn->prepare($sql);
  8. $stmt->execute();
  9. $stmt->bind_result($month,$year);
  10.  
  11. $rows = array();
  12.  
  13. while($row = $stmt->fetch())
  14. {
  15. $item = array(
  16. 'blog_month' => $month,
  17. 'blog_year' => $year
  18. );
  19. $rows[] = $item;
  20. }
  21. $stmt->close();
  22. return $rows;
  23. }

Report this snippet  

You need to login to post a comment.