Jump to content

Help displaying Now & Next events form sql database


hotmert

Recommended Posts

Ok so, I have a database with loads of upcoming events. The events hay and 'id' key byt NOT inputted in sequence, but are sorted by date for output to a listing page. I am attempting to show a snippit from that listing and show on my homepage i.e. now and next events.

 

It kinda worked but now it's not. It seems to show either no next event or the next 'id' event.  The first time i wrote and tried the code it worked but now two days later is gone a bit wrong.

 

This is what I have going at the moment to get the now and next onto homepage


$sql = "(SELECT date, time, event, bands FROM listings WHERE date = CURDATE() LIMIT 1 ) UNION (SELECT date, time, event, bands FROM listings WHERE date > CURDATE() LIMIT 1 )" or die(mysql_error());

 

https://www.thefiddlerselbow.co.uk

 

https://thefiddlerselbow.co.uk/gig_guide.php

 

I just noticed at 05:57 GMT that the next event has appeared but its the next id event not date event...Obviously it's using US time....humm

 

So I guess help the code works but a tweak on the code to get it to show the now and next events on date not id would help.

 

Thanks for looking, these forums are so good when your head is full no ideas.

Link to comment
Share on other sites

Just tried that and it did the same thing, however I tried this and at the moment it seems to work.  Just added ORDER BY date before the LIMIT 1


$sql = "(SELECT date, time, event, bands FROM listings WHERE date = CURDATE() ORDER BY date LIMIT 1) UNION (SELECT date, time, event, bands FROM listings WHERE date > CURDATE()ORDER BY date LIMIT 1) "

Link to comment
Share on other sites

Yeah it is one table.  I could not work out the code to display so I used UNION.  By the way today its not working again.

 

It may not always be, that there is something on "today".  So show the next date and the next one after that event if the next date is today. Now I'm confused.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.