Page 1 of 1

PHP_mysql doubt..

Posted: Wed Apr 15, 2009 4:55 am
by sanju
Hi all.

I need to display a list of classifieds as the heading will be date and there will be list of classifieds under that list. I also need pagination for the page.. How I should write the optimized query for above.
eg:-
Wed Apr 15

Im looking for the total package - 28 - (Financial District) pic
from nc to ny need a friend? - 26 - (Harlem / Morningside) pic

Tue Apr 14

it can't all the time - 28 - (williamsburg)
Care to join me? I'm lonely - w4m - 20 -


Regards

Re: PHP_mysql doubt..

Posted: Wed Apr 15, 2009 10:49 am
by McInfo
It is difficult to write a query without any knowledge of the table structure. The query might look something like this, though.

Code: Select all

SELECT `ad_id`, `post_date`, `teaser`, `age`, `location`, `has_pic`
FROM `want_ads`
ORDER BY `post_date` DESC
LIMIT 0, 100
As you loop through the results in your PHP script, you can check whether the post_date for the current record is the same as the post_date for the previous record. If it is different, output a new date heading.

Edit: This post was recovered from search engine cache.