Topic: displaying posts

I'm having a lot of fun working on SlickCMS, and I'm finally adding the whole blog/news aspect to it.  The basics are almost done, but I can't get more than one post to display on a page.  Here's what I have:

<?php $title='News';
include("inc/header.inc.php");
if(!isset($_GET['title'])){ ?><h1>News Archive <a type="application/rss+xml" href="news.xml"><img src="images/rss.png" alt="News RSS Feed" /></a></h1><?php }
    include('inc/mysql_connect.inc.php');
    $db_table = 'news';
    if(isset($_GET['title'])){
        $title = $_GET['title'];
        $query = 'SELECT * FROM ' . $db_table . ' WHERE SLUG=\'' . $title . '\'';
        }
    else{
        $query = 'SELECT * FROM ' . $db_table;
        }
    $result = mysql_query($query);
    if($result){
        $row = mysql_fetch_array($result);
        }
    else {
        echo 'Could not query the database! ' . mysql_error();
        }
    
    $num_rows = mysql_num_rows($result);
    $i=$num_rows;
    while($i>0){
        $query = 'SELECT * FROM ' . $db_table . ' WHERE ID=\'' . $i . '\'';
        $result = mysql_query($query);
        if($result){
            $row = mysql_fetch_array($result);
            }
        else {
            echo 'Could not query the database! ' . mysql_error();
            }

        if($row['status']=='publish'){
            if(isset($_GET['title'])){echo '<h1>';}else{echo '<h2>';}
            echo $row['title'];
            if(isset($_GET['title'])){echo '</h1>';}else{echo '</h2>';}
            echo '<p class="date">' . $row['date'] . '</p>
            ' . $row['post'];
            $db_table = 'slick_users';
            $query = 'SELECT * FROM ' . $db_table . ' WHERE ID=' . $row['author_id'];
            $result = mysql_query($query);
            if($result){
                $row = mysql_fetch_array($result);
                }
            else {
                echo 'Could not query the database! ' . mysql_error();
                }
            echo '<p class="author">Posted by ';
            if(!empty($row['url'])){
                echo '<a href="' . $row['url'] . '">';
                }
            echo $row['displayname'];
            if(!empty($row['url'])){
                echo '</a>';
                }
            echo '</p>';
            }
        echo $i;
        $i--;
        } ?>
<?php include("inc/footer.inc.php"); ?>

You can see the data in the database as array values by viewing this page.  What am I doing wrong?  I'm kinda making this up as I go along...

Re: displaying posts

I finally figured it out.  In the middle of the while loop, I changed the value of $db_table to the users table in order to access the author information.  So all I had to was change it back at the beginning of the loop to 'news' in order to be accessing the right data.  Thanks for looking!