Low End Mac's Online Tech Journal

Managing External Links

Website Automation with PHP and MySQL, Part 9

Low End Mac Reader Specials

Memory To Go Special: MacPro 8 Core Memory 4GB kit $154 / 2GB kit $94, New 2008 iMac 2GB $46. 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: Specials on AppleCare, iMac's, Apple Batteries and Apple A/C Adapters. Also Great prices on Used Apple Computers. Call 1-800-941-7654 Click Here.

OWC: Juice up your iPod w/NewerTech High Capacity Battery from $19.99 Free Installation Videos for most models. Pro Installation Service w/FedEx Shipping From $57.95 (Battery Included). - www.MacSales.com

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 $90 / 4GB $134 / 8GB $264. Click to Maximize your Macs...

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:

  1. Category
  2. Linked text
  3. URL
  4. Author, when known
  5. Column name, not always present
  6. Website
  7. Date of publication
  8. 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.

Recent Online Tech Journal Columns

Links for the Day

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!

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