Ordering Question

Hello everyone,

I have recently starting working for a marketing company and they've asked me to do some script editing for some fine-tuning of websites that were already put together by other people employed by them.  I've been dropped into a project where the original script writer developed his own content management system.  This way, the client can go in and change or add new materials.

I’ve been asked to change a couple of things, but I’m going to address just one here:

There is a tab on the left column of the pages that is supposed to list the next coming event that this restaurant group is hosting. The original code writer wrote the following to render the content:

$vals=$db->GetMultipleArray(“Select id, title, descr, date_format(date,’%d %M %Y’) from news where shw=1 and date>”.date(“Y-m-d”)." ORDER BY rand() LIMIT");

Obviously this only supplies any random event that comes after today’s date. However, I’ve been trying to sort out the code so that it displays only the NEXT event, and I’ve tried this:

$vals=$db->GetMultipleArray(“Select id, title, descr, date_format(date,’%d %M %Y’) from news where shw=1 and date>”.date(“Y-m-d”)." ORDER BY STR_TO_DATE(Date, ‘Y-m-d’) DESC");

Which still doesn’t seem to work. In the content management, the client adds events and the dates are saved in the following format in the input field: yyyy-mm-dd if that helps…

Thanks in advance!

Richard

Sponsor our Newsletter | Privacy Policy | Terms of Service