Re: [PHP] how to display photos of the day?



At 6:33 PM +0800 1/29/08, jeffry s wrote:
sorry if this question sound stupid.
i need a good, simple and efficient function to display lets say photo of
the day.

i have a mysql table contain data about 1000 rows. i want to display any of
the photos randomly
and it is fixed for one day.

anyone know how to write the function that return a fixed table id for the
day?


What I would do is something like this (assuming your table has a column 'filename' in it):

Create a cron job (on windows, I think the command is called 'at'?) that runs this query

select filename from photo_table order by rand() limit 1

once per day, then copies that file to a predefined location (eg images/pic_of_the_day.jpg).

Then, your web page simply refers to images/pic_of_the_day.jpg. The contents of pic_of_the_day.jpg change every time the cronjob runs (unless you randomly pick the same picture twice; not likely with 1000 rows, but you could include some sort of flag [eg; last used date] to avoid picking the same image twice, or to cycle through all images before reusing them).

This requires one database hit per day, returning one row, so the load is next to nothing.

The cronjob could be written in any language, but since this is a PHP list you'll have to promise to write it in PHP ;)

steve


--
+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg http://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center sbedberg@xxxxxxxxxxx |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+---------------- said t e lawrence, picking up his fork ----------------+
.



Relevant Pages

  • how to display photos of the day?
    ... simple and efficient function to display lets say photo of ... i have a mysql table contain data about 1000 rows. ...
    (php.general)
  • Re: [PHP] how to display photos of the day?
    ... simple and efficient function to display lets say photo of ... i have a mysql table contain data about 1000 rows. ...
    (php.general)
  • Re: Looking for a digital photo album
    ... Make a copy of the files you want to display and save the originals. ... The Windows Photo Viewer has a slide show feature, or you can advance them manually. ... Same with graphic viewers, most if not all stand alone DVD players, even ... You can have a specific screen effect or capton etc. to any specific ...
    (alt.photography)
  • Re: Printing question
    ... a Dell Latitude x300 laptop and an Epson Stylus Colour 760 printer. ... The only way I've been able to 'correct' this is to lighten the photo images so they look like they're over exposed when displayed on screen but they print out ok. ... Also someone who thought they knew what they were doing thought the problem would be solved by altering my screen settings, but all that's done is to make my display darker, it doesn't seem to have changed the difference between display and print brightness at all ... and has built-in settings for using Kodak papers with most printers. ...
    (rec.photo.digital)
  • Re: DPI
    ... most computer monitors are only ... capable of displaying 72-100 dpi. ... photo will be 10" x 6.7". ... photo on doesn't have the resolution to display 300 dpi, ...
    (alt.photography)