Automatically select "next" image from database daily?
Posted: Wed May 07, 2008 10:20 pm
Hi everyone,
I'm fairly new to PHP and MySQL, and there's something I'm trying to do that I can't quite figure out. If anyone can provide some insight I'd appreciate it.
What I want to do is store an image file name in a MySQL database, linked to a sequentially-assigned number (1, 2, 3, etc.) that would be the primary key. Then, in the PHP code that displays the image, I want to retrieve and display the data associated with primary key #1. The next day (at midnight?) I want to display the next image, associated with primary key #2. Then after that, the image associated with #3, etc.
It sounds like this is what I need to have happen:
PHP code, when the page is called, displays image associated with primary key #1.
Server date/time advances to the next day.
PHP code, sensing the server date/time, increments the primary key up by one. When the page is called, it displays the image associated with primary key #2.
So, first, does this logic sound right?
Second, any direction I should follow when writing this?
I'm just now learning PHP and MySQL, so any assistance would be wonderful. Thanks!
Dave
I'm fairly new to PHP and MySQL, and there's something I'm trying to do that I can't quite figure out. If anyone can provide some insight I'd appreciate it.
What I want to do is store an image file name in a MySQL database, linked to a sequentially-assigned number (1, 2, 3, etc.) that would be the primary key. Then, in the PHP code that displays the image, I want to retrieve and display the data associated with primary key #1. The next day (at midnight?) I want to display the next image, associated with primary key #2. Then after that, the image associated with #3, etc.
It sounds like this is what I need to have happen:
PHP code, when the page is called, displays image associated with primary key #1.
Server date/time advances to the next day.
PHP code, sensing the server date/time, increments the primary key up by one. When the page is called, it displays the image associated with primary key #2.
So, first, does this logic sound right?
Second, any direction I should follow when writing this?
I'm just now learning PHP and MySQL, so any assistance would be wonderful. Thanks!
Dave