Several ways to do this. In concept it is simple.
1) Store each language translation in a different place
2) Store a users preference for a language somewhere
3) Have php choose between language storage locations at page load time
Here is vanilla pseudo-code example :
1) In sql you could store one translation table per language
PRODUCT: id, cost
PRODUCT_EN: id, english_description
PRODUCT_ES: id, spanish_description
2) In sql store a language preference
USERS: id, login, password, language
3) When grabbing the product from the database
so now [url]http://...../viewproduct.php?product=100[/url]
<?php
/// find their language preference from database. assuming you know login already
$user = SELECT * FROM USERS WHERE login = $login
/// now $user->language = 'ES'
/// so join your product table with your language table to get description
$product = SELECT * FROM PRODUCT P, PRODUCT_{$user->language} L where P.id = L.id AND P.id = $_GET['product']
/// now $product->description = 'something in spanish'
?>
Now essentially you would have to store each translatable sections of text on the page somewhere in a database of some kind. This could get tedious.
I believe if you use SMARTY Templates to render your html there is a translation or internationalization plugin/addon that will do this language lookup for you based off flat files instead of database tables, but essentially the concept is the same. You would wrap arbitrary text in a language tag {l}like this{/l}. Upon rendering time smarty would look for a language preference, then pull out the text in the tag, see if it has a translation anywhere and replace it with prewritten translation if found.
essentailly the smarty structure would look like this is described in SQL
LANGUAGE_EN: text, translation
LANGUAGE_ES: text, translation
Where "text" is an arbitrary block of text, or maybe just an md5 of the text, and the translation is the translated text you have to have gotten ahead of time.