Top

News


PHP Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Feb 22, 2008
Last Updated  Feb 22, 2008
Tags  news 

Introduction

Very basic News

Grab the Code

<?php
// NEWS-----------------------------------------------------NEWS
  $nn = 0;
  $query="select * from `News` order by id desc;";
  $qu = mysql_query($query);
  while (($n_obj = mysql_fetch_object($qu)) && ($nn<10)) {
    printf("<table class =\"news\">\n<tr><th>%s : <span class=\"news_tp\">%s</span></th></tr>\n", $n_obj->date, $n_obj->title);
    printf("<tr><td>%s -<span class=\"auth_nm\">%s</span></td></tr>\n</table><br>",$n_obj->body, $n_obj->author);
    $nn = $nn + 1;
  }
  mysql_free_result($qu);
 
?>

Comments

  (2)  RSS
jonesy44
Comments: 1,856
 
PHP Snippet:  News
Posted on Feb 24, 2008 4:57 pm
i dont believe you need $nn, php 4.0 + auto inc's a result from an sql table, correct me if im wrong, but that's how i've been doing it for a year or so
LordHawk
Comments: 30
 
PHP Snippet:  News
Posted on Feb 24, 2008 6:43 pm
Im rather new to php, ive only been writing php for alittle over 4 months now. I am still learning the easier ways of writing php.

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom