Changeset 160 for branches

Show
Ignore:
Timestamp:
05/29/06 23:02:55 (2 years ago)
Author:
michiel
Message:

put authors stuff inside it's own function

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/asze/common/functions_blog.php

    r158 r160  
    8787                header("Location: login.php"); 
    8888        } 
     89} 
     90/* }}} */ 
     91/* get_authors() {{{ */ 
     92/** 
     93 * Get all the authors into an array. 
     94 */ 
     95function get_authors() { 
     96        $res =& $GLOBALS["db"]->query("SELECT * FROM authors"); 
     97        if (PEAR::isError($res)) { 
     98                die($res->getMessage()); 
     99        } 
     100        while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
     101                $authors[$row["id"]] = $row["fullname"]; 
     102        } 
     103        return $authors; 
    89104} 
    90105/* }}} */ 
     
    164179function show_article($id) { 
    165180        //get all the authors in an array 
    166         $res =& $GLOBALS["db"]->query("SELECT * FROM authors"); 
    167  
    168         if (PEAR::isError($res)) { 
    169                 die($res->getMessage()); 
    170         } 
    171  
    172         while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
    173                 $authors[$row["id"]] = $row["fullname"]; 
    174         } 
     181        $authors = get_authors(); 
    175182        //same with categories 
    176183        $res =& $GLOBALS["db"]->query("SELECT * FROM categories"); 
     
    716723         
    717724        //get all the authors in an array 
    718         $res =& $db->query("SELECT * FROM authors"); 
    719         if (PEAR::isError($res)) { 
    720                 die($res->getMessage()); 
    721         } 
    722         while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
    723                 $authors[$row["id"]] = $row["fullname"]; 
    724         } 
     725        $authors = get_authors(); 
    725726        //same with categories 
    726727        $res =& $db->query("SELECT * FROM categories");