Low End Mac Reader Specials
TypeStyler For Mac OS X is Now Shipping! Download The Free Fully Functional 60 Day Tryout at www.typestyler.com
Don't install Parallels to play poker online! Poker Mac will show you how
to download and install a native Mac poker application such as Full
Tilt Poker Mac.
Compare products like desktop computers, apple laptops, apple macs, and LCD Monitors side by side! All the information and reviews to make the best purchasing decision for new mobile phones, sat nav systems, or MP3 players. The Ciao online shopping community makes searching products easy for you.
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.
Recent Online Tech Journal Columns
- Optimized Software Builds Bring Out the Best in Your Mac, 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, 06.15. What is Safe Sleep mode? Which Macs support it? How can you enable or disable it? And more.
- The Original Macintosh, 01.12. An in-depth look at the original Macintosh and how it shaped future Macs.
- The Innovative Lisa, 01.08. Apple's Lisa and how it paved the way for the Macintosh.
- More in the Online Tech Journal index.
Links for the Day
- Mac of the Day: Mac Pro, Aug. 2006 - The last Mac to go Intel, the Mac Pro has two dual-core Xeon CPUs at 2.0-3.0 GHz. 8-core option added in 2007.
- Group of the Day: Mac mini List is for anyone using or contemplating a Mac mini
- March 20 in LEM history: 00: Adobe isn't making friends - Raising the dead - 01: Milking the Mac for all it's worth, - 02: Keeping the Web free - Macally CardBus USB - 05: Copyright bullies - 07: The iPhone: Is it a Mac? - Improve productivity with a second display - 08: The rise of the Microsoft monopoly
- Support Low End Mac
Recent Content on Low End Mac
- Does iPhone OS Need Multitasking?, iCab Comes to iPhone, Canada's Proposed iPod Levy, and More, iNews Review, 03.19. Also the iPad paradox, Freescale demos $200 tablet, gardening apps, aluminum iPhone stand, steel iPhone case, and more.
- Could iPad Replace the Mac?, Mac Sales Up in 2010, Avoiding Windows 7 'Whenever Possible', and More, Mac News Review, 03.19. Also why your next Mac may be an iPad, science blogger abandons Apple, the benefits of standing while working, and more.
- The Mobile System Stampede, Lithium Battery That Can't Explode, Affordable SSD Options, and More, The 'Book Review, 03.19. Also June 2007 MacBook Pro external display issue, laptop stands, 1 TB ultraportable hard drive, Mini DisplayPort/HDMI adapter, and more.
- CardBus WiFi, the Shiira Browser, Ridding the Web of Flash, and Macs vs. PCs, Charles W. Moore, Miscellaneous Ramblings, 03.18. Mac longevity, Shiira speed, ambidextrous Mac and Windows use, and how Flash benefits Apple.
- How to Zoom Your Browser for a More Readable Web, Steve Watkins, The Practical Mac, 03.18. Instructions for zooming text and pages in Safari, Firefox, Camino, and Opera.
- How Ad Blocking Hurts Your Favorite Websites, Charles W. Moore, Miscellaneous Ramblings, 03.18. Ad income keeps the Web free. Blocking online ads hurts your favorite websites.
- Taking Apart the 12" PowerBook, John Hatchett, Recycled Computing, 03.17. There are a lot of steps involved in disassembling a 12" PowerBook. Proceed with caution.
- More links in our archive.
Recent Deals
- Best Intel iMac Deals, 03.17. Used 17" from $600; 20" from $750; 24" from $825; refurb 21.5" nVidia, $999; new, $1,099; refurb Radeon, $1,299; new, $1,399; refurb 27" 3.06, $1,499; more.
- Best G5 iMac Deals, 03.17. 17" 2.0 GHz, $380; 1.9 GHz iSight, $479 shipped; 20" 1.8 GHz, $509 shipped; 2.1 GHz iSight, $549 shipped.
- Best Time Capsule Deals, 03.17. Close-out 500 GB, $140; new 1 TB, $279; used 2 TB simultaneous dual-band, $400; new, $455. Shipping included.
- Best iPad Deals, 03.16. 16 GB iPad, $499; 32 GB, $599; 64 GB, $699; 16 GB with 3G, $629; 32 GB 3G, $729; 64 GB 3G, $829. Free ground shipping.
- Best iPod classic Deals, 03.12. Used 20 GB, $119; 40 GB, $139; 60 GB, $159; 30 GB video, $129; 60 GB, $159; 80 GB, $169; refurb 120 GB, $189; new, $214; 160 GB, $228 shipped.
- Best G3 iBook and AirPort Card Deals, 03.12. 366 MHz 12" clamshell, $89; 466, $125; 500 white CD, $100; 600, $199; 800 Combo, $239; 14" 900, $225.
- Best Xserve Deals, 03.12. Used 1 GHz dual G4, $499; 2.0 dual G5, $599; 2.3, $749; refurb 2.26 4-core Nehalem, $2,499; new, $2,699; 8-core, $3,449; refurb 2.66, $4,299; new, $4,799; more.
- More deals in our archive.
About LEM | Support | Usage | Privacy | Contacts
Navigation
Used Mac Dealers
Apple History
Video Cards
Email Lists
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
B&H
MacMall
TechRestore
ExperCom
Crucial
Memory
batteries.com
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
Mac Connection
B&H
MacMall
TechRestore
ExperCom
Crucial Memory
batteries.com
