Page 1 of 1
quote a day system with mySQL database
Posted: Sat Jun 30, 2007 9:43 am
by suthie
I am trying to make something that shows a different quote every day. Before I get started, I want to make sure there is not an easier way to do this.
I was planning to create a mySQL table with two rows, "date" and "quote". This will link a quote to a date so php can grab a different quote each day.
I have two questions:
1. When I am putting in all the quotes and dates, what is the most efficient way to do this?
2. How should I format the date? Should I make it an eight digit number like 06302007 so I can use
when preparing to fetch the quote??
Posted: Sat Jun 30, 2007 10:00 am
by feyd
Use an automatic sortable date format, such as "Ymd" or similar. You can convert it to "readable" forms afterward, if necessary. Alternately, use the database's own standard field and format.
Posted: Sat Jun 30, 2007 7:23 pm
by suthie
okay, yeah that makes sense for the date. in Ymd it can sort it by numerical value and actually put them in chronological order in doing so.
And what is the best way to put in these loads and load of quotes?
Posted: Sat Jun 30, 2007 7:30 pm
by superdezign
To put them in? Input is input. There's no generally quick way to make loads and loads of quotes. Just do them little by little.
You'll probably want them managed through an administrative section.
Posted: Sat Jun 30, 2007 7:34 pm
by suthie
There is a file upload option in phpmyadmin... can I upload an excel spreadsheet with all the data?
Posted: Sat Jun 30, 2007 7:45 pm
by superdezign
I don't do much with phpMyAdmin, but I know that it can export excel files. Not sure about importing.
If you want, you can export it into a CSV format (comma separated) and make a tiny PHP script that takes that data in a text fields, explodes the data into an array, and loops through it, entering it into the database.
Posted: Sat Jun 30, 2007 7:47 pm
by suthie
that sounds like about the same amount of work. it looks like im just going to have to put it all in by hand....
thanks!
Posted: Sat Jun 30, 2007 8:00 pm
by superdezign
suthie wrote:that sounds like about the same amount of work. it looks like im just going to have to put it all in by hand....
thanks!
It's actually easier to write a script than enter it all by hand.
Posted: Sat Jun 30, 2007 8:09 pm
by califdon
I opt for writing my own little plain-and-simple PHP script and entering it online. If you use your imagination a little, you can make it easier than inputting to a spreadsheet first, and you won't have to hassle uploading it. For example, you could have yours advance the date for each new record. I just did that with a somewhat complex series of ship's rosters, to add about 2,500 names, ranks and dates to an online searchable database for my old Navy ship. What made it complex was that the rosters were quarterly and I had to be careful not to enter the same person multiple times, so I just entered the last name, it checked for possible dupes, either displayed them with links to records, if any were found, or displayed a new form with the last name already filled in, if there were no dupes, so I could continue and enter the remaining data. It wasn't a pretty form, but it reduced my input effort quite a bit.
I have had a joke-of-the-day on my personal web page for years (
http://ravey.net). Guess it's about time I refreshed the jokes, huh? That page also displays a small graphic for holidays and such; right now, it's displaying an American flag for the 4th of July. That's done from a MySQL table that has columns for date-to-begin, date-to-end and URL to the image. I tried to figure out how to incorporate the calculation for Easter each year but gave up when I read how weird it is!