Jump to content

displaying news


velocite

Recommended Posts

Hi everyone, I am kinda new to this PHP coding thing, I was wondering if you guys could help me with this:

 

<?php
    include('connect.php');
    include('config.php');

    $query = mysql_query("SELECT * FROM news ORDER BY news_id DESC");
    $totalnews = @mysql_num_rows($query);
    $i = "0";

    if ($totalnews == '0') 
    {
     echo "<div class='nonews'>";
     echo     "News has not been added.";
     echo "</div>";
    }
    else 
    {
      
        while($row = mysql_fetch_array($query))
        {
        	
		$news[$i]['news_id'] = $row[$i]['news_id'];
		$news[$i]['news_title'] = $row[$i]['news_title'];
		$news[$i]['news_body'] = $row[$i]['news_body'];			
		echo "
		        <div class='newshead'>
					".$news[$i]['news_title']."
        			</div>
       				 <div class='newsbody'>
            			".$news[$i]['news_body']."
        			</div>
        			</br>
				";

		$i++;
		}
          }          
?>

 

what i am trying to do is basically connect to the database, then try using classes to get and display the news by its news_id. I have no idea what I am doing wrong, as it isn't displaying the news.

 

Please help, thanks everyone

Link to comment
https://forums.phpfreaks.com/topic/93072-displaying-news/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.