Grabbing the last 50 entries in a database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
haptic
Forum Newbie
Posts: 11
Joined: Fri Sep 08, 2006 7:21 pm

Grabbing the last 50 entries in a database

Post by haptic »

Hi, I'm just trying to grab the last 50 entries in a database ordered by their id number. The problem is the syntax I'm using just grabs 1-50, and I'm not sure why.


Here is my query:

Code: Select all

$query = "SELECT * FROM analyst ORDER BY id DESC LIMIT 50";
Yet it seems to order them by 'name' rather than 'id', because it is showing entries 1-50 ascending (rather than what should currently be entries 67 through 17).

Any idea what to do?

thanks...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The query appears fine to me... are you sure the code is using it?
haptic
Forum Newbie
Posts: 11
Joined: Fri Sep 08, 2006 7:21 pm

Post by haptic »

whoops. A closer look at my code made me realize that it wasn't running that query, the problem appears to be solved. Sorry for wasting your time, and thanks for your help.
Post Reply