Jump to content


Two questions


2 replies to this topic

#1 Korndawg

    Young Padawan

  • Members
  • Pip
  • 111 posts
  • Gender:Male
  • Location:Texas, USA

Posted 11 October 2006 - 03:46 PM

Ok so I work for a band and im writing a script that will display there shows. (Tour Page) I also want to make a page that will display the closest show thats coming up.

Ok so I was wondering if there was a way to write a snippet that would delete entrys that have already passed. As in if the show is on the 3rd, and today is the 4th, it would automatically delete that entry from mysql. I was planning on putting this snippet into the "shows" page, so everytime someone visits that page it will check to see if any entrys need to be deleted.

Next question is how do I select an entry from mysql that is on the closest date coming up to the current one?

I probably need to describe a little more, just let me know.

#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 11 October 2006 - 04:15 PM

Well, for the selecting part, you would simply use something like this.
Provided you have a 'date' field that is a DATETIME field type.
mysql_query("SELECT * FROM `concerts` ORDER BY `date` DESC") or die (mysql_error());

For the deleting, I would use a cronjob (if I could get them to work, lol, even Cpanel can't help me XD).
But still, the code would be something like this.
mysql_query("DELETE FROM `concerts` WHERE UNIX_TIMESTAMP(date) < now()") or die (mysql_error());

I might have the wrong method of using a current timestamp, you may have to assign a variable and use the time() function or something.
Someone may have to correct me lol, that's my one main weakness with coding... time and date methods. :wacko:

Edited by Demonslay, 11 October 2006 - 04:16 PM.


#3 Korndawg

    Young Padawan

  • Members
  • Pip
  • 111 posts
  • Gender:Male
  • Location:Texas, USA

Posted 12 October 2006 - 02:32 PM

Where can I learn more about these "cronjobs"?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users