1. this belongs into a programming subforum.
2. Here is a code you can start with. Add it above the header of your website and design an own iphone optimized website for your content and put it to the path you provided here.
(the path I used is just an example. You can use whatever you want)
PHP Code:
<?php
$browser = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
if ($browser == true) {
header('Location:http://yourwebsite.com/iphonefriendly/index.php');
}
?>
To see how it works, visit
http://iphone.3dmagicbox.com on your PC and on your iphone. You will see the difference (not on ipad!).