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:
- ID, just a simply integer that automatically increments
- URL, the URL for the day's special, up to 128 characters long
- text, our long description of the day's special, up to 64 characters
- short, a shorter description for the navigation bar, up to 32 characterss
- extra, used for tracking code required by some affiliate programs, up to 128 characters
- 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.
Recent Online Tech Journal Columns
- Optimized Software Builds Bring Out the Best in Your Mac, 2009.06.30. Applications compiled for your Mac's CPU can load more quickly and run faster than ones compiled for universal use.
- Low End Mac's Safe Sleep FAQ, 2009.06.15. What is Safe Sleep mode? Which Macs support it? How can you enable or disable it? And more.
- The Original Macintosh, 2009.01.12. An in-depth look at the original Macintosh and how it shaped future Macs.
- More in the Online Tech Journal index.
Links for the Day
- Mac of the Day: Macintosh Portable, introduced 1989.09.20. The nearly 16 lb. behemoth was innovative but not a smashing success.
- February 13 in LEM history: 01: Layoffs may hurt Mac market - 02: Unix for the Mac - Rage against the Macintosh - 03: Options to move data from PCs to Macs - 04: Low cost RAM for older 'Books - 06: Apple, IBM, and Intel - 07: Picking the right cheap computer, new or used - 08: I needed to find an older Mac
- Support Low End Mac
Recent Content on Low End Mac
- Fix Home Button Delay, Tablet the Ultimate Mobile PC, iPad Notebook a Possibility, and More, iOS News Review, 2012.02.10. Also using your iPad at work, two photo editors, a new iPad text editor, Macally's magnetic iPad 2 stand, and more.
- White MacBook Goes End-of-Life, Logitech Touch Mouse Supports Gestures, Firmware Updates, and More, The 'Book Review, 2012.02.10. Also MacBook Air better than any Ultrabook, docks for MacBook Pro models, Intel offers improved SSDs, and more.
- Mac and iOS Browsers: Options Galore, Freeware Forum, 2012.02.10. Safari is adequate on Mac and great on iOS, but the range of good alternatives is stunning. LEM writers share their favorites.
- Apple's Support Lead Shipping, Smartphones Outsell PCs, OS X Ported to ARM by Intern, and More, Mac News Review, 2012.02.10. Also the power of Tex-Edit Plus, Google and Twitter are already censoring the Web, Snow Leopard Security Update, and more.
- LogMeIn: Remote Screen Sharing for the Rest of Us, Alan Zisman, Zis Mac, 2012.02.09. Configuring the Mac's built-in screen sharing to work over the Internet can be difficult or impossible. LogMeIn makes it easy.
- 15 Years Ago Motorola Unveiled the PowerPC G3, Low End Mac Round Table, 2012.02.06. The G3 processor was optimized for real world Mac software and made a big leap forward in efficiency.
- Don't Kill Caps Lock, Learning to Love the iOS Keyboard, and an Adaptive iPad Keyboard, Charles W. Moore, Miscellaneous Ramblings, 2012.02.06. The Caps Lock key has a useful function, the iPad's keyboard really is useful, and checking out an adaptive keyboard for the iPad.
- More links in our archive.
Recent Deals
- Best MacBook Air Deals
- Best iBook G4 Deals
- Best iPad Deals
- Best Classic Mac OS Deals
- Best Apple TV Deals
- Best 15" MacBook Pro Deals
- Best Power Mac G4 Deals
- Best Mac OS X 10.6 Deals
- More deals in our archive.
About LEM Support Usage Privacy Contact
Follow
Low End Mac on Twitter
Join Low End Mac
on Facebook
Low End Mac Reader Specials
TypeStyler 11 is now in the Mac App Store!! -- Special Introductory Price of $59.95!! -- To Buy From The Mac App Store Click Here Now!! Or buy direct
from Strider Software.
Don't install Parallels to play poker online! Poker Mac will show you how to download and install a native Mac poker and Mac Casino applications in minutes.
Favorite Sites
MacSurfer
Cult of Mac
Shrine of Apple
MacInTouch
MyAppleMenu
InfoMac
The Mac Observer
Accelerate Your Mac
RetroMacCast
PB Central
MacWindows
The Vintage Mac Museum
DealMac
Deal Brothers
Mac2Sell
Mac Driver Museum
JAG's House
System 6 Heaven
System 7 Today
the pickle's Low-End Mac FAQ
Affiliates
Amazon.com
The Apple Store
The iTunes Store
PC Connection Express
GainSaver
Parallels Desktop for Mac
eBay

