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.

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) "

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.