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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.