Jump to content

Archived

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

rich_greeny

PHP won't display newest value from mysql database

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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
wooo, thanks a bunch. I've done small amounts of programming, but the whole 'not defining the variables' kind of threw me!

Thanks

Share this post


Link to post
Share on other sites

×

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.