Low End Mac's Online Tech Journal

The Deal of the Day Database

Website Automation with PHP and MySQL, Part 7

Low End Mac Reader Specials

Memory To Go Special: MacPro 8 Core Memory 4GB kit $192 / 2GB kit $109. MacBook Pro / MacMini / iMac Intel Core2 DUO 2GB $44 1GB $23--Free shipping available.

Download Typestyler, still the Ultimate Styling Tool for Internet, Print and Video Graphics. Works great in Classic with a Native OS X Version on the way. Free Tryout: www.typestyler.com

LA Computer Company: LA Computer Company: Specials on AppleCare, Apple Displays, MacBooks, iMac's, MacBook Pros, Laptop and iPod accessories and more. Apple A/C Adapters for laptops starting at $25.00 Call 1-800-941-7654 or Click Here.

OtherWorld Computing: Better than new Batteries for iPods NewerTech NuPower, up to 20+ Hours! Complete with Tools from $19.99. Online videos. Professional installation available.

Mac users can finally play Party Poker for Mac. Not only that, they can also learn how to play PokerStars for Mac.

Laptop Hardware Provided by TechRestore - Overnight Mac & iPod Repairs.

Compare products like desktop computers, laptops, and LCD TVs side by side! All the information and reviews to make the best purchasing decision for a new cell phone GPS products or MP3 players. The Ciao network makes searching products easy for you.

MacPro Memory 667Mhz With Apple Spec Heat Sink 2GB Kit $ 90 / 4GB Kit $140 / 8GB Kit $278 Click to Maximize your Macs...

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. LEM

Recent Online Tech Journal Columns

Recent Content on Low End Mac

Go to the Online Tech Journal index.

About LEM | Support | Usage | Privacy | Contacts


Have a question?
Ask an expert!

Low End Living

Amazon.com

Navigation

Used Mac Dealers
Apple History
Best Used Macs
Video Cards
Email Lists
InfoMac's Low
End Mac Forum

Favorite Sites

MacSurfer
MacMinute
MacInTouch
MyAppleMenu
InfoMac
Macs Only!
The Mac Observer
Accelerate Your Mac
RetroMacCast
PB Central
MacWindows
The Vintage Mac
   Museum

DealMac
DealsOnTheWeb
Mac2Sell
ramseeker
Mac Driver Museum
JAG's House
System 6 Heaven
System 7 Today
the pickle's Low-End
   Mac FAQ

Abandonware
   Petition

Mac vs. PC Info

Affiliates

The Apple Store
Mac Connection
MacMall
TechRestore
MacResQ
ExperCom
Crucial Memory
batteries.com

Advertise

Open Link