NYCPHP Meetup

NYPHP.org

archive the news to 'next page'

deedee delta at rochester.rr.com
Sun May 18 08:46:02 EDT 2003


if you would like to see what i'm working on at www.keitz.org, 
below the banner i have some 'news' i retrieve from a mysql database.
i'm trying to do something that i'm sure is done on everysite... the news is getting overwhelming for the homepage so i  thought i'd put a link to the 'archives'.

in order to use the code (sql_calc_found_rows) i wanted to use i had to upgrade .... finally i'm getting somewhere with the following code.

$query = "SELECT SQL_CALC_FOUND_ROWS DATE_FORMAT(Newsdate,'<CENTER>%W<BR>%D %M %Y %r</CENTER>'),
News FROM www_news ORDER BY NewsDate DESC limit 3;";

$result = mysql_query($query,$link);
if (!$result) {
die("<h2>!queryErr - error executing query.</h2><br>$query");
}

$sql_news_count = "SELECT FOUND_ROWS()";

$count_news_results = mysql_result (mysql_query ( $sql_news_count ),3);

//print "<B>News ($count_news_results):</B>";

<TH bgcolor="#A0A0A0" width="70%" nowrap>3 of <?print ($count_news_results);?> news articles</TH>
<TH bgcolor="#A0A0A0" width="15%" nowrap>Archives</TH>

<?


$AltColor ="#F0F0F0";


while ($field = mysql_fetch_row($result)) {

$Date =$field[0];
$News =$field[1];

print("<TR>");

print("<TD colspan=\\"3\\"bgcolor=\\"$AltColor\\"><CENTER><FONT color=\\"#0000A0\\">$Date<BR>$News</CENTER></TD>");
print("</TR>");

if ($AltColor == "#F0F0F0") {
$AltColor = "#E0E0E0";
}

else {
$AltColor = "#F0F0F0";
}

}


?>

SO...... i'm going to make an HREF for the word Archives to something like new1.php and then i need to somehow start a new starting reference point to display the news.  i know i have counted the total available news accurately because i got 11 when i put in the code  //print "<B>News ($count_news_results):</B>"; i guess i need to somehow define a variable that is equal to $count_news_results minus the three news articles i previously displayed.  but at somepoint i need a loop to end when i run out of news.  

i must be brain dead this morning....cuz i'm sure this is common code. thanks for any help you can offer.

regards,

deedee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20030518/ae2e43cc/attachment.html>


More information about the talk mailing list