Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
fariquzeli
Forum Contributor
Posts: 144 Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:
Post
by fariquzeli » Mon Jul 22, 2002 2:08 pm
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 {
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 );
?>
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
fariquzeli
Forum Contributor
Posts: 144 Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:
Post
by fariquzeli » Mon Jul 22, 2002 3:04 pm
nm, figured it out, thanks guys!
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Tue Jul 23, 2002 2:24 am
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
fariquzeli
Forum Contributor
Posts: 144 Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:
Post
by fariquzeli » Tue Jul 23, 2002 11:46 am
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ї'headline'];
$id = $row_newsї'id'];
echo("messagesї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)) {
$headline = $row_newsї'headline'];
$id = $row_newsї'id'];
echo("messagesї$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++;
}
?>
That retrieves the last 3 results using a mysql fetch array and repeats it twice.