Hi, I'm extremely new with both MySQL and PHP, and I'm having a problem with my code. Hopefully someone here can point me in the right direction. I'm using some of my knowledge of C++, which may or may not be the right thing to do.
What I'm trying to do is display a certain number of news items (starting with the most recent), and display them in standard HTML tables. Here's my code:
if($show)
{
$total_news = mysql_query("SELECT COUNT() FROM news");
$allnews = mysql_query("SELECT FROM news, authors WHERE aid = authors.id");
for($i=$total_news; $i>$total_news-$show; $i--)
{
$news=mysql_fetch_array($allnews)
$subject=$news["subject"];
$summary=$news["summary"];
$fullnews=$news["fullnews"];
$date=$news["date"];
$time=$news["time"];
$username=$news["username"];
echo("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"darkbd\">");
echo("<tr>");
echo("<td class=\"bluecn\"><font class=\"whitenmb\">Posted by: <a href=\"contact.php\">$username</a> on $date at $time</font></td>");
echo("</tr><tr>");
echo("<td class=\"ltblue\"><font class=\"blacksmb\">$subject</font></td>");
echo("</tr><tr>");
echo("<td class=\"ltblue\"><font class=\"blacksm\">$summary</font></td>");
echo("</tr>");
echo("</table>");
echo("<br>");
}
}
One obvious problem is that even though the for loop moves backwards (starting with the total number of news items and decreasing from there), the mysql_fetch_array still starts at the first news item (instead of the last, where I need it to). However, that shouldn't cause an error, even though its incorrect. When I run the script, I get this error:
Parse error: parse error, unexpected T_VARIABLE in c:\path to news\news.php on line 59
Line 59 has: $subject=$news["subject"];
Hopefully someone can help me out here, since my tutorial doesn't really go this far into creating a news script. I thank you very much in advance.