SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Zealot JonathanS's Avatar
    Join Date
    Jun 2004
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Converting site to use OOP for mysql, date won't show

    Code:
    <?php
    session_start();
    
    // Set the page title
    $title = "Last Entry.com - Home";
    
    // Set the Description Meta Data
    $dmeta = "Description Meta Data";
    
    // Set the Keyword Meta Data
    $kmeta = "Keyword Meta Data";
    
    // Require the class fil
    require_once('rf/class.php');
    
    // Require the News Page System
    require_once('rf/nps.php');
    
    // Require the header file
    require_once('rf/head.php');
    
    $blog = $_GET['blog'];
    
    // Connect to MySQL
    $db = & new MySQL($host,$dbUser,$dbPass,$dbName);
    
    if (isset($blog)) {
    
    // Set up the query...
    $gdnps = "SELECT id, author, title, msg, email, DATE_FORMAT(date, '%h:%i - %m.%d.%y'), blog";
    $gdnps .= " FROM gdnps WHERE blog='$blog' ORDER BY id DESC LIMIT $from, $max_results";
    
    // Perform said query
    $result = $db->query($gdnps);
    while ($row = $result->fetch()) {
    
    $id = $row['id'];
    $entryauthor = $row['author'];
    $entrytitle = $row['title'];
    $entrytext = $row['msg'];
    $email = $row['email'];
    $date = $row['date'];
    $blog2 = $row['blog'];
    
    // Grab a count...
    $csql = "SELECT * FROM comments WHERE news_id='$id' ";
    $cresult = $db->query($csql);
    
    	// Build the output right here
    echo "<div class=\"title\">$entrytitle</div>";
    
    echo "<div class=\"normal\">[ Posted by $entryauthor @ $date | ";
    echo "<a href=\"comments.php?id=$id\" class=\"doc\">Read</a> / ";
    echo "<a href=\"reply.php?id=$id\" class=\"doc\">Reply</a> / ".$cresult->size()." Replies ] </div>";
    
    	}
    } else { 
    
    // send a query to the mySQL database
    $sql = "SELECT id, blog FROM blog ORDER BY blog ASC";
    $result2 = $db->query($sql);
    
    while ($row2 = $result2->fetch()) {
    $id2 = $row2['id'];
    $blog3 = $row2['blog'];
    
    echo "<div class=\"title\">Current List of Blogs</div>";
    echo "<div class=\"normal\">$blog3 -> <a href=\"blog.php?blog=$blog3\" class=\"doc\">Click here to view</a> <br /></div>";
    
    }
    	}
    
    require_once('rf/np.php');
    require_once('rf/foot.php');
    
    ?>
    Okay, now it works.. but I can't get the $date var to show up;
    I have a simular problem on nearly the same code for a different
    page, which shows a news post + the comments below it.

    Any idea what I'm doing wrong??
    (And yes, I know its not good code w/ all the $var = $row['blah'] but I'm lazy, forgive me)

  2. #2
    SitePoint Zealot tcwatts's Avatar
    Join Date
    Jan 2003
    Location
    .my
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think you need to state select DATE_FORMAT(date, %blah) AS fdate. Then you can use 'fdate' to show.

  3. #3
    SitePoint Zealot JonathanS's Avatar
    Join Date
    Jun 2004
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! That did the trick.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •