Announcement

Collapse
No announcement yet.

SQL query for limiting events to future ones only by specific user

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MikaK
    replied
    Thank You

    Originally posted by Colin F View Post
    Try this:

    PHP Code:
    $eventshosted $DB_site->query("
    SELECT eventid,userid,title,customfields,dateline_from 
    FROM " 
    TABLE_PREFIX "event 
    WHERE userid = '
    $userinfo[userid]' AND dateline_from > UNIX_TIMESTAMP()
    ORDER BY dateline_from ASC 
    LIMIT 
    $limit_page1
    "
    ); 
    This worked. Thank you for your effort, Colin.

    Best regards,
    -Mika

    Leave a comment:


  • Colin F
    replied
    Try this:

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

    Leave a comment:


  • SQL query for limiting events to future ones only by specific user

    Following sql query gets all events for a specific user

    PHP Code:
    $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
    1. picks events by userid and events occuring later than the present moment (time difference settings are not of importance)
    2. 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

Related Topics

Collapse

Working...
X