Low End Mac's Online Tech Journal

The Deal of the Day Database

Website Automation with PHP and MySQL, Part 7

Dan Knight - 2002.05.13

The Deal of the Day database will need several fields:

  • ID
  • URL
  • description
  • short description
  • extra
  • date

The ID will be a unique integer that automatically increments itself. The next four fields will contain text and be of type char, which allows them to be up to 256 bytes long. The date field is the date that the deal should be displayed and will be of type date.

Dates in MySQL

There are many ways to enter dates. Here in the States, most people would write today's date at 5/13/02. In most other English-speaking regions, it would be written 12/5/02. Since the Web is international, that gets confusing in a real hurry.

To address this, Low End Mac began by dating articles like this: 13 May 2002. No confusion, but a mess if you want to sort dates. We later settled on the format YYYY.MM.DD, since it simplifies sorting. It's also an international standard.

While Unix uses a timestamp, that number needs to be converted to years, months, days, hours, minutes, and seconds so we humans can make sense of it. MySQL and PHP also support the YYYY-MM-DD format for dates. Since we're not worried about date stamps and want to make it easy to schedule our Deal of the Day for a specific date, that's the format we'll use.

Creating Six Fields

We've got six fields. After analyzing field lengths from our specials of the day over the past months, we came up with the following:

  1. ID, just a simply integer that automatically increments
  2. URL, the URL for the day's special, up to 128 characters long
  3. text, our long description of the day's special, up to 64 characters
  4. short, a shorter description for the navigation bar, up to 32 characterss
  5. extra, used for tracking code required by some affiliate programs, up to 128 characters
  6. date, the date the special is scheduled to appear, this is also the index field for our database

That gives us a template to pour our data into - except that in this case there isn't a text file or database to import. We'll be adding our Deal of the Day one at a time, so the next project is designing a Web-based front end for editing our database and adding new records.

Join us on Facebook, follow us on Twitter or Google+, or subscribe to our RSS news feed

Today's Links

Recent Content

About LEM Support Usage Privacy Contact

Follow Low End Mac on Twitter
Join Low End Mac on Facebook

Page not found | Low End Mac

Well this is somewhat embarrassing, isn’t it?

It seems we can’t find what you’re looking for. Perhaps searching, or one of the links below, can help.

Most Used Categories

Archives

Try looking in the monthly archives. :)

Page not found | Low End Mac

Well this is somewhat embarrassing, isn’t it?

It seems we can’t find what you’re looking for. Perhaps searching, or one of the links below, can help.

Most Used Categories

Archives

Try looking in the monthly archives. :)

Favorite Sites

MacSurfer
Cult of Mac
Shrine of Apple
MacInTouch
MyAppleMenu
InfoMac
The Mac Observer
Accelerate Your Mac
RetroMacCast
The Vintage Mac Museum
Deal Brothers
DealMac
Mac2Sell
Mac Driver Museum
JAG's House
System 6 Heaven
System 7 Today
the pickle's Low-End Mac FAQ

Affiliates

Amazon.com
The iTunes Store
PC Connection Express
Macgo Blu-ray Player
Parallels Desktop for Mac
eBay

Low End Mac's Amazon.com store

Advertise

Well this is somewhat embarrassing, isn’t it?

It seems we can’t find what you’re looking for. Perhaps searching, or one of the links below, can help.

Most Used Categories

Archives

Try looking in the monthly archives. :)

at BackBeat Media (646-546-5194). This number is for advertising only.

Open Link