displaying news heading from mysql database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
magreth
Forum Newbie
Posts: 3
Joined: Mon May 08, 2006 12:36 am

displaying news heading from mysql database

Post by magreth »

hi
im looking for a way i can display news heading from database and when a user click the link heading will be directed to the news page
thanx in advance
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

On a page you presumably could grab all newsheadlines (sorted by date, and only a certain number using LIMIT), list them on a page, use each to create a link holding the full articles row id, then have the second page grab the entire news article and display it...

You can post any code you have if you require more assistance :)
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Here's the code sample :

Code: Select all

          
  <?php

			  $i=1;

			  $sql_fetch_news="select * from news order by date desc limit 0,10";

			  $rs_fetch_news=mysql_query($sql_fetch_news)or die(mysql_error());

			  while($news=mysql_fetch_assoc($rs_fetch_news))

			  {

			  ?>

              <tr> 

                <td align=left valign="top" height="13">

                  <?=$i?>

                  . <a href="news_details.php?id=<?=$news["news_id"]?>"> 

                  <?=$news["news_headline"]?>

                  </a> (

                  <?=$news["news_date"]?>

                  ) </td>

              </tr>

              <?php

				  $i++;

			  }//end while

			  ?>
Post Reply