PHP problem
Posted: Fri Nov 04, 2011 9:49 am
I am trying to get this php script to go to my database gather all the data from my news table and display it in a table, however it only displays the most recent record and I cannot figure out why, I might be making a stupid mistake but cannot see anything wrong with it, any suggestions would be appreciated. Cheers.
Code: Select all
<?php
include 'dbconnect.php';
$newsquery = mysql_query('SELECT * FROM news');
if (!$newsquery)
{
die ('<p> Error performing query: ' .mysql_error() . '</p>');
}
while($nq = mysql_fetch_array($newsquery))
{
$newsid = $nq['ID'];
$newsdate = $nq['date'];
$newstext = $nq['news'];
}
?>
<table border = "1">
<tr><th>ID</th><th>Date</th><th>News</th></tr>
<?php
echo ("<td>$newsid</td>\n");
echo ("<td>$newsdate</td>\n");
echo ("<td>$newstext</td>\n");
?>
</tr>
</table>