tan go
tan go

Reputation: 23

displaying last SQL database record on the top row in a html table in PHP

Hi below code prints results from first saved to last saved. Is there a way to get last saved on the top row once the data is displayed? (All records in the reverse order.) thanks.

while ($recz = mysql_fetch_array($runz))
{

    echo "<tr class='taB'>";
    echo "<td>".$recz["chkNum"]."</td>";
    echo "<td>".$recz["InvoNum"]."</td>";
    echo "<td>".$recz["InvoVal"]."</td>";
    echo "<td>".$recz["InvoDate"]."</td>";
    echo "<td>".$recz["type"]."</td>";
    echo "<td class='ta'>".$recz["statu"]."</td>";
    echo "</tr>";
}

Upvotes: 2

Views: 411

Answers (1)

Travesty3
Travesty3

Reputation: 14479

You will need to change your query. Use ORDER BY ... DESC, where the ... is the column name that determines the order of the results.

In your HTML output, it looks like you have a column named InvoDate. Perhaps that's the column you need. If so, your query would end with ORDER BY InvoDate DESC.

Upvotes: 2

Related Questions