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
OWC: Plug & Play Hardware RAID up to 8.0TB. High Performance, Data Redundant Solutions. FireWire 800, FireWire 400, USB2, or eSATA. Hot Swappable Bays, Data Rates over 200MB/s. Click here
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.
Laptop Hardware Provided by TechRestore - Overnight Mac & iPod Repairs.
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
Creating Your My SQL Database
Website Automation with PHP and MySQL, Part 2
Dan Knight - 2002.04.24
What is PHP? I can't summarize it any better than Try a New Language: PHP:
- PHP is an open-source, server-side, cross-platform scripting language that is used to generate dynamic Web pages or to build browser-based applications. The PHP script can be embedded in the HTML page to generate HTML code that is inserted in the Web page at that point, or the PHP script can generate the entire HTML output. One of PHP's strengths is easy database integration.
That database integration usually comes from a MySQL database, another open-source standard. For our purposes, creating a database will be the first thing we do - before we even begin programming in PHP. (And it's all free.)
Creating the Mac of the Day Database
The first piece of Low End Mac we be automated was the Mac of the Day. I have a list of nearly 100 Apple models and clones, along with a page link and a brief note on the model's significance. Here's what the Mac Plus entry looks like in HTML:
- <A HREF="/compact/macintosh-plus.html">Mac Plus</A> (1/86-10/90). First Mac with SCSI, memory expansion. Longest model life - over 4 years.
We could create a database containing that entire text string or create one with separate fields for the link, the model name, and the description. Neither system is inherently better than the other, but using three fields will create a system where editing the description could be done with no risk of messing up the link or the model name. It will also have a second benefit, which I'll mention later.
MySQL has three types of string or text records. (Other record types are numeric and time-related.) The CHAR type uses fixed length strings, while VARCHAR allows variable string lengths. Although that's a more efficient use of space, VARCHAR adds overhead and reduces performance. Both of these field types are limited to 255 characters, which will be plenty for our needs.
The third string record is BLOB or TEXT fields, which can be as large as 65,535 characters. We might use such fields when we work with mailing lists and articles, but we don't need such large fields right now.
The longest model name is under 30 characters, and the longest link is just over 20 characters, so we'll give ourselves a bit of room and give the model name field a maximum length of 32 and the link a maximum size of 24 characters.
A few of the descriptions are around 100 characters, so we'll set the maximum size for that text field to 128 characters.
To create the database, you'll need to log into the MySQL server you'll be using. Your ISP or system administrator should be able to provide all the information you need to do that. If you're using Telnet, type the following at the prompt to create your database:
mysql> create database macs;
This creates an empty database named "macs" - and it's just waiting for us to create a table for our data. We'll be creating the following fields:
mysql> CREATE TABLE mod ( -> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> link CHAR(24), -> model CHAR(32), -> text CHAR(128), -> );
The first line creates a table called "mod" (Mac of the Day") within our database. The first field gives each record a unique and automatically created ID number with a maximum value way up there in the billions. PRIMARY KEY declares id as the primary field in this table, meaning it is the one MySQL will index and access most readily.
- NOTE: I didn't do it this way. My son Brian <http://brkn.net/> told me about a program called PHPMyAdmin that's much easier than using Telnet.
All that remains is to move the data from my current HTML file into MySQL.
Filling the Mac of the Day Database
Call me lazy, but I simply don't want to spend a lot of time rekeying this information or doing the cut-and-paste thing.
.
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: 15" MacBook Pro Core Duo, Jan. 2006 - The first Intel-based MacBook launched at 1.83-2.0 GHz, had several teething problems.
- Group of the Day: System 6 is the email list for those who choose System 6.
- November 22 in LEM history: 99: Gradebooks - 00: Leveraging Apple design - Quadra 630 to Power Mac 5200 - 02: Laptop or desktop? - 04: SuperDuper: Quick, easy, efficient backup - Cross-platform programming for the rest of us - 05: Mac video surveillance on the cheap - Which OS is best for my vintage Mac? - No 'best browser' for the Mac - Sorry state of browsers for classic Macs - 06: Core 2 means cooler running 'Books - 2.0 GHz G4 upgrade
- Support Low End Mac
Recent Content on Low End Mac
- Apple's Tablet an End Run Beyond Netbooks, Frank Fox, Stop the Noiz, 11.20. Whatever Apple has planned will leverage existing technologies while going beyond what its competitors can offer.
- i5 iMac Benchmarked, Mac mini 'Shouldn't Be Overlooked', Twitter Client for Classic Mac OS, and More, Mac News Review, 11.20. Also why Apple leaves the low end to others, 10.6.2 fixes video playback problem in 27" iMac, 3D Leopard and Snow Leopard performance, and more.
- Apple #4 in Reliability, Apple Tablet a Gadget for All?, HP's i7 Notebook Outdoes Mac Rivals, and More, The 'Book Review, 11.20. Also Flash 10.1 improves video on Hackintosh netbooks, thin-and-light notebooks impress, Windows XP finally on the way out, and more.
- NASA Chemical Sensor for iPhone, Smartphone Death Match, iPhone Earrings, and More, Ian R Campbell, 11.20. Also mobile phone dangers, new apps, GPS solution for iPod touch, new iPod and iPhone cases, and more.
- Replacing the Hard Drive in a Clamshell iBook, John Hatchett, Recycled Computing, 11.19. Yes, it is one of the most difficult Apple notebooks to disassemble and reassemble, but a 10 GB hard drive just will not do.
- IBM Model F: A Great Old Keyboard with an Outdated Layout, Tommy Thomas, Welcome to Macintosh, 11.19. Although it used a different technology than the revered IBM Model M keyboard, the Model F was a great keyboard in its own right.
- Soft Touch Keyboards, Wireless Mouse Options, Loving SeaMonkey 2, and More, Charles W. Moore, Miscellaneous Ramblings, 11.18. Also the future of browsing with PowerPC Macs and the multiple mouse input bug introduced with OS X 10.5.8.
- More links in our archive.
Recent Deals
- Best eMac Deals, 11.18. Used 1 GHz Combo, $100; SuperDrive, $269; 1.25 GHz Combo, $119; SD, $319; 1.42 GHz Combo, $289; SD, $498.
- Best Mac OS X 10.6 and Mac Box Set Deals, 11.18. "Snow Leopard", single user, $25; 5 users, $45; Mac Box Set, single user, $139; 5 users, $180; Server, $414. Shipping included.
- Best Xserve Deals, 11.18. Used 1 GHz dual G4, $649; 2.3 dual G5, $795; 3.0 4-core Xeon, $1,899; refurb 2.26 4-core, $2,499; new, $2,888; refurb 8-core, $2,999; new, $3,449; more.
- Best 15" MacBook Pro Deals, 11.17. Used 1.83 GHz, $750; 2.16, $800; 2.33, $900; refurb 2.4, $1,299; 2.53, $1,449; 2.66, $1,699; 2.8, $1,899; new 2.53, $1,579; 2.66, $1,799; more.
- Best Power Mac G4 and AGP Video Card Deals, 11.17. Used 400 MHz, $50; 933 MHz, $80; 500 dual, $60; 867 dual, $90; 1 GHz dual, $150; 1.25 GHz dual, $225; 1.42 GHz, $499.
- Best Mac OS X 10.5 Deals, 11.17. "Leopard" upgrade, $80; single user license, $135; 5 users, $173; Mac Box Set, 5 users, $230; Server, 10 users, $340; unlimited, $850. Shipping included.
- Best Mac mini Deals, 11.16. Used 1.42 GHz G4 mini, $379; 1.66 GHz Core Solo, $419; 2.0 Core 2, $450; new 2.26 GHz nVidia, $580; 2.53 GHz, $769; Server, $990.
- Best iBook G4 Deals, 11.16. Used 12" 1.07 GHz Combo, $210; 1.33 GHz, $298; 14" 1.33 GHz, $398; 1.42 GHz, $479; SuperDrive, $498.
- Best iPod shuffle Deals, 11.16. Used 1 GB, $35; 4 GB, $65; refurb 1 GB, $39; 2 GB, $59; new 2 GB, $55, 4 GB, $75. New and refurb prices include shipping.
- 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
Advertise
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
