Sql Order

Status
Not open for further replies.

Chris2k

Banned
Banned
901
2009
17
0
hi

um, ok heres an SS:

[slide]http://i.lulzimg.com/591e92dd0f.png[/slide]

they're ordered by date, which is fine but theirs 40 sites per page, so the above is an SS from page 1. sites are blacklisted daily so i need the most recent records on the 1st page...

heres what i havve atm:

PHP:
$query = mysql_query("SELECT * FROM wcddl_blacklist ORDER BY ".$core->sqlOrder." dat DESC LIMIT ".$start.", ".$pageLimit."");

how to do this?
 
7 comments
well you wont be able to unless you have a better way to get the exact end...

So the table all your urls are being entered into insert a new table that auto increments...

so it goes 1,2,3,4,5...

From which you would do the order by (your increment number table) DESC
 
doh y didnt i think of tht?

so ill make a field called id, then how to give my current sites an id?

+ will the id start from 8 mnths ago, first ever site gets id #1 or it starts now?
 
well best thing i can think of is just start the auto increment at the last number of how many records you got and slowly add the numbers on your own unless you can figure a way to edit the existing tables and place a id...
 
Yes it should take te first inserted to the last unless you have it using and index.

So when you use phpmyadmin to alter the table or however you do it it should take first to last inserted when the field is added.
 
hi is thr any other way besides adding 'id' field - auto-increment? as i hagve to delete an index coz auto has 2 be an index thn i get dupes...

My date is a INT (11)
 
Auto can be a primary key and it should never duplicate. But you shouldn't need an id if date is the date the site is added to the database.

But you have to have more in that record than what you are showing us.

It seems the order you are doing should work. If you do not want banned sites in the list then you have to add another where saying do not include banned.

But date reverse order should give you the last ones entered in database first.
 
Status
Not open for further replies.
Back
Top