Jump to content

PHP won't display newest value from mysql database


rich_greeny

Recommended Posts

Hi all, i'm new to php and mysql, but starting to get the hang of it with my comp sci student housemate. I'm trying to return values inserted via a text box, but the top entry in the database won't display. If you add another to the database, then it appears, anyone have any ideas, or code to resolve the issue?

Cheers

Rich

[blockquote]$sql = "SELECT * FROM $table_name ORDER BY 'date' DESC";
$result = mysql_query($sql,$connection) or die("Couldn't execute SELECT query");
$row = mysql_fetch_array($result);
while ($row = mysql_fetch_array($result)){
echo "<tr>
<td style=\"width: 87px;\" height=\"0\"> </td>
<td>$row[notice]
</td>
</tr>";
}
mysql_close();
?>[/blockquote]
Remove this line:
[code]<?php $row = mysql_fetch_array($result); ?>[/code]
You are getting the first line, not doing anything with it and then getting all the others. Once you remove that line you will be getting all the lines.

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.