Low End Mac's Online Tech Journal
Managing External Links
Website Automation with PHP and MySQL, Part 9
Dan Knight - 2002.06.24
I've been thinking long and hard about automating different parts of the site and making the manual three-times-a-day updates a thing of the past. The last three pieces are handling new articles online, tracking new content, and working with links to content on external sites.
Last week I decided it was time to sit down and create a MySQL database for those outside links. Once the system is in place, new links will be available on the Low End Mac home page as well as the iMac Channel, iBook & PowerBook Page, Power Macintosh page, and WebTV index immediately. We'll still be manually adding content to some other pages, but our frontline link pages can have fresh outside links several times during the day.
Crucial Fields
There's a lot involved here, starting with the fields needed to create and track these articles:
- Category
- Linked text
- URL
- Author, when known
- Column name, not always present
- Website
- Date of publication
- Description
I didn't have to break things down that thoroughly, but this will eventually let me search the database by author, website, or column name to see if some sites or writers tend to receive more clicks - but that's a topic for a future column.
After wading through two months of link archives, we came up with about 20 categories ranging from News and Opinion to AAPL and Oops. We also came up with fairly extensive names of authors and websites. These lists are something we'll deal with later.
I also needed one more category, Flag, to display a U.S., Canadian, U.K., or Australian flag when an article has a specific national focus. That's eight fields.
Helpful Fields
Because publication date isn't always the same as the date we add a link - sometimes we link to a week old article, and other times the article has a publication date several days in the future - we added a Unix timestamp field. With an ID field to number our database entries, that brings us to 10 fields.
We've been adding articles to the database for a few days and went live on Saturday. Sometime today we'll remove the last few manually added links from the home page, and you'll probably never even notice the change, except that new links in the "Around the Web" section are being added more frequently.
Implementation
The only glitch we ran into when creating the MySQL database comes from the fact that MySQL timestamps are not the same as Unix timestamps. In fact, they're not even close. A MySQL timestamp for today would begin 20020624..., while a Unix timestamp is the number of seconds since 1970.01.01.
We have future plans that make the MySQL timestamp problematic, so we changed that field to an integer. More on that when we're ready to make some changes to our display system.
Follow Up
A month ago I promised to look at the PHP code that displays our deal of the day. Sorry it took so long, but here it is:
- $dod = date(Ymd);
- $query = mysql_fetch_array(mysql_query("select * from deals where date = '$dod'"));
- echo "<li>Deal of the Day: <a href=\"$query[URL]\">$query[text]</a>$query[extra]</li>";
As always, a million thanks to my son Brian <http://brkn.net/> for his help with the PHP and MySQL.
And next time we'll look at some of the coding necessary to
display data when some fields may be empty.
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 12 in LEM history: 99: $4,320 for a 'free' iMac - 01: 10 Commandments of Macintosh - High-end word processing for free - 02: 8 OS X gotchas - Working less with my Mac than with my PC - Microsoft Office v. X - 03: New Zealand's Mac mag - 04: Nothing else is a Mac - 07: On Mighty Toaster Wings - Jobs stirs up DRM hornet's nest - OS X 10.2 best for Classic? - 08: Too much software choice is not a blessing - A month with Windows
- 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

