PDA

View Full Version : Sql SQL Query for limiting events to future ones only


MikaK
08-30-2006, 09:50 AM
Following sql query gets all events for a specific user


$eventshosted = $DB_site->query("
SELECT eventid,userid,title,customfields,dateline_from
FROM " . TABLE_PREFIX . "event
WHERE userid = '$userinfo[userid]'
ORDER BY dateline_from ASC
LIMIT $limit_page1
");


the problem is, that it shows the very first event the user ever posted

Is there a way to change the above so it

picks events by userid and events occuring later than the present moment (time difference settings are not of importance)
and then orders only those future events to be shown in ascending order by the limited amount as defined by $limit_page1?I guess the secret lies in changing the WHERE part to include some additional filter?

Thanks for any ideas,
-Mika

Colin F at vbulletin.com kindly advised the answer.

In case of interest to anyone the workin solution is:

WHERE userid = '$userinfo[userid]' AND dateline_from > UNIX_TIMESTAMP()

MikaK
09-09-2006, 02:25 PM
case solved and closed.