quote a day system with mySQL database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
suthie
Forum Commoner
Posts: 68
Joined: Sat Jun 09, 2007 10:46 am

quote a day system with mySQL database

Post 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

Code: Select all

date('mdY');
when preparing to fetch the quote??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
suthie
Forum Commoner
Posts: 68
Joined: Sat Jun 09, 2007 10:46 am

Post 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?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
suthie
Forum Commoner
Posts: 68
Joined: Sat Jun 09, 2007 10:46 am

Post by suthie »

There is a file upload option in phpmyadmin... can I upload an excel spreadsheet with all the data?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
suthie
Forum Commoner
Posts: 68
Joined: Sat Jun 09, 2007 10:46 am

Post 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!
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post 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!
Post Reply