I have this bit of code:
$query = "SELECT * FROM shows ";
but I want it to just grab the last record created in that table and if no record is present then to type a mesage saying "No shows available for results" or something like that.
Only Show Lasat Record
Moderator: General Moderators
-
CoolAsCarlito
- Forum Contributor
- Posts: 192
- Joined: Sat May 31, 2008 3:27 pm
- Contact:
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: Only Show Lasat Record
Have you got a field in the database which could define what order the records were created? For example, an auto-incremented ID or a date inserted field?
I assume you have, and in that case, use something like this:
Also, please use [ code ] [ /code ] tags in your posts.
I assume you have, and in that case, use something like this:
Code: Select all
SELECT * FROM `table` ORDER BY `id` DESC LIMIT 1