Announcement

Collapse
No announcement yet.

PHP + MySQL News System

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Chexbox
    replied
    How did you get started writing this News System?

    Leave a comment:


  • k@mi
    replied
    thanks!

    Leave a comment:


  • Mark Hensler
    replied
    Just throw an IF statement in there.
    PHP Code:
    //Defining the data retrieval loop
    $tmp_date "";
    while(
    $query_data mysql_fetch_object($result)) {
        if (
    $tmp_date != stripslashes($query_data->date)) {
            
    // It's a new day, print the date
            
    $tmp_date stripslashes($query_data->date);
            echo 
    "<hr noshade>";
            echo 
    "<span class='date'>"
            echo 
    "<img src='styles/$style_name/bullet.gif' class='bullet'>".stripslashes($query_data->date)."</span>";
            echo 
    "<hr class='bottom' noshade>";
        }
        echo 
    "<span class='p'><img src='styles/$style_name/bullet.gif' class='bullet'><span class='newstitle'>"stripslashes($query_data->subject) ."</span><img src='styles/$style_name/bullet.gif' class='bullet'>";
        echo 
    "<a href='$PHP_SELF?page=$page&mode=filter&div=".stripslashes($query_data->category)."'>".stripslashes($query_data->category)."</a> - ";
        echo 
    stripslashes($query_data->user) ."</span>";
        echo 
    "<span class='p2'>"stripslashes($query_data->message) ."</span>";

    Leave a comment:


  • k@mi
    replied
    here's the code i'm using now
    PHP Code:
        //selecting the 'kidzonfire' database to use
        
    mysql_select_db("kidzonfire");
        
        
    //Hey Look, it's todays damn date...
        
    $today date("l F dS Y"); 
        
        
    //Setting the default mode for the news script
        
    if(!isset($mode))
            {
                
    $mode "news";
            }
            
        if (
    $mode == "news")
            {
                
    //This is the printnews part of the code, prints a specified number of news posts in the format specified here
                //MySQL Query Stuff here
                
    $query "SELECT * FROM news ORDER BY newsid DESC LIMIT 0,30";
                
    $result mysql_query($query);
                
                
    //Defining the data retrieval loop
                    
    while($query_data mysql_fetch_object($result))
                         {    
                            echo 
    "<hr noshade>";
                            echo 
    "<span class='date'>"
                            echo 
    "<img src='styles/$style_name/bullet.gif' class='bullet'>".stripslashes($query_data->date)."</span>";
                            echo 
    "<hr class='bottom' noshade>";
                            echo 
    "<span class='p'><img src='styles/$style_name/bullet.gif' class='bullet'><span class='newstitle'>"stripslashes($query_data->subject) ."</span><img src='styles/$style_name/bullet.gif' class='bullet'>";
                            echo 
    "<a href='$PHP_SELF?page=$page&mode=filter&div=".stripslashes($query_data->category)."'>".stripslashes($query_data->category)."</a> - ";
                            echo 
    stripslashes($query_data->user) ."</span>";
                            echo 
    "<span class='p2'>"stripslashes($query_data->message) ."</span>";
                        }
                        
                
    //Closing the mysql connection
                
    mysql_close($db);
            
            }
            
        if (
    $mode == "filter")
            {
                
    //This is the printnews part of the code, prints a specified number of news posts in the format specified here
                //MySQL Query Stuff here
                
    $query "SELECT * FROM news WHERE category='$div' ORDER BY newsid DESC LIMIT 0,30";
                
    $result mysql_query($query);
                
                
    //Defining the data retrieval loop
                    
    while($query_data mysql_fetch_object($result))
                         {    
                            echo 
    "<hr noshade>";
                            echo 
    "<span class='date'>"
                            echo 
    "<img src='styles/$style_name/bullet.gif' class='bullet'>".stripslashes($query_data->date)."</span>";
                            echo 
    "<hr class='bottom' noshade>";
                            echo 
    "<span class='p'><img src='styles/$style_name/bullet.gif' class='bullet'><span class='newstitle'>"stripslashes($query_data->subject) ."</span><img src='styles/$style_name/bullet.gif' class='bullet'>";
                            echo 
    "<a href='$PHP_SELF?page=$page&mode=filter&div=".stripslashes($query_data->category)."'>".stripslashes($query_data->category)."</a> - ";
                            echo 
    stripslashes($query_data->user) ."</span>";
                            echo 
    "<span class='p2'>"stripslashes($query_data->message) ."</span>";
                        }
                        
                
    //Closing the mysql connection
                
    mysql_close($db);
            
            } 
    I use the date thing to get the calendar date of the time a news post was posted, and i want it to check if the two dates are the same, and if they are, the most recent post will be towards the top.

    Leave a comment:


  • k@mi
    started a topic PHP + MySQL News System

    PHP + MySQL News System

    I've written most of the code to the thing, but the part i'm faltering on is how to get the news posts with the same date to appear under the same date header

    Site: http://www.kidzonfire.org/new/

    i'm playing around with stuff, but i'm stumped on how to do that

    -----------
    Date
    -----------
    *Subject
    Message

    *Subject
    Message

    -----------
    Date
    -----------

    etc.........
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X