Page 1 of 1

error trying to print last 3 db entries

Posted: Mon Jul 22, 2002 2:08 pm
by fariquzeli
here is my code:

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);
?>

<?php
$i = 0;
do &#123;
echo("messages&#1111;$i-1]='<font face=verdana color=#ffffff size=1>$row_news&#1111;'headline']</b><br> :<a href=http://www.yiinc.com/news.php?id=$row_news&#1111;'id']><font color=#cccccc>Full Story</a></font>");
$i++;
&#125;
while ( $i < 3 );
?>
I now the formatting is wrong on that echo and it's real ugly, just wondering if anyone had a better way to format that line, here's the error i get:
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!

Posted: Tue Jul 23, 2002 2:24 am
by twigletmac
Please don't cross-post. If you're going to move your topic to another forum note that in the original post so you don't end up with two active threads about the same thing.

Oh and if you solve your problem tell people how you did it, it might help someone else along the line...

Mac

Posted: Tue Jul 23, 2002 11:46 am
by fariquzeli
the reason for the cross post was that i changed the post almost entirely and decided it was more suited for the db forum.

here's the final code and how i got this solved:

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 LIMIT 3";
$news = mysql_query($query_news, $ydntNews) or die(mysql_error());
$row_news = mysql_fetch_assoc($news);

$headline = $row_news&#1111;'headline'];
$id = $row_news&#1111;'id'];

echo("messages&#1111;0]="<font face='verdana' color='#ffffff' size='1'>$headline</b><br> :<a href='http://www.yiinc.com/news.php?id=$id'><font color='#cccccc'>Full Story</a></font>"\n");

$i = 1;

while ($row_news = mysql_fetch_array($news)) &#123;
$headline = $row_news&#1111;'headline'];
$id = $row_news&#1111;'id'];

echo("messages&#1111;$i]="<font face='verdana' color='#ffffff' size='1'>$headline</b><br> :<a href='http://www.yiinc.com/news.php?id=$id'><font color='#cccccc'>Full Story</a></font>"\n");
$i++;
&#125;
?>
That retrieves the last 3 results using a mysql fetch array and repeats it twice.