Page 1 of 1
printing last 3 db entries
Posted: Mon Jul 22, 2002 1:56 pm
by fariquzeli
how do you get the last 3 db entries to be printed out. I have the mysql_fetch_array function, but i'm only sure on how to print out the field entries for one row, does anyone have a really generic example or a good bit of code to work off of?
another problem is that i will be parsing this inside of some javascript (if that's possible)
Posted: Mon Jul 22, 2002 2:06 pm
by twigletmac
What does your code currently look like?
Mac
Posted: Mon Jul 22, 2002 2:12 pm
by fariquzeli
Code: Select all
<?php require_once('Connections/ydntNews.php'); ?>
<?php
mysql_select_db($database_ydntNews, $ydntNews);
$query_news = "SELECT * FROM news ORDER BY id DESC";
$news = mysql_query($query_news, $ydntNews) or die(mysql_error());
$row_news = mysql_fetch_assoc($news);
$totalRows_news = mysql_num_rows($news);
$i = 0;
do {
echo("messagesї$i-1]='<font face=verdana color=#ffffff size=1>$row_newsї'headline']</b><br> :<a href=http://www.yiinc.com/news.php?id=$row_newsї'id']><font color=#cccccc>Full Story</a></font>");
$i++;
}
while ( $i < 3 );
?>
the reason for the messages[]= is because this is going to be used within a javascript, and the $i-1 is so that it uses the proper javascript message id, i know the formatting is terrible and i dont know how to format it better, here is the error i get with that code as well:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/ttoomey/ydnt.com/messageTest.php on line 13
Posted: Mon Jul 22, 2002 3:04 pm
by fariquzeli
nm, figured it out, thanks guys.