I have a live update system for a football team, which I input the following:

Date, Score, Event (Goal, Red card, Yellow Card, none), Details

So 4 columns.

At the top of the page, I want to display the latest score, so bascially I want to grab whatever the current score is and display that at the top.

This is the page:

http://www.corkcityfc.net/updates

I've hard coded in the "2-1" at the top of the page to show you what I mean.

I've tried messing around but can't get it to work. Any ideas?

Recommended Answers

All 3 Replies

I also have each row labelled with a "row_id" column.

So bascially, I must take the most recent "score" entry from the last row_id and display it at the top.

Try this one:

SELECT Score FROM scores ORDER BY row_id DESC LIMIT 1;

Aquilax* solution supposes that the entry date cannot be changed manually after inserting the records. If it can, the query should rather read

SELECT Score FROM scores ORDER BY [B]date[/B] DESC LIMIT 1;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.