написал простенький скрипт корзинки, поделитесь кто знает, как его можно сделать лучше, какие ошибки допустил, впервый раз пишу просто PHP: #cart.php <? session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> <title>Тест</title> </head> <? if(!isset($_SESSION['c']) OR count($_SESSION)<=1){ echo "Корзина пуста"; } else{ mysql_connect("localhost","root",""); mysql_select_db('test_promo'); $c = $_SESSION['c']; $cc = range(1,100); for($i=1;$i<=$c;$i++){ foreach ($cc as $number) { if(in_array($number,$cc)){ if($number == $i){ if(!empty($_SESSION['item_id'.$number])){ $sql = "SELECT * FROM `".$_SESSION['tab_'.$number]."` WHERE cid=".$_SESSION['item_id'.$number]; $d = mysql_query($sql); while($line = mysql_fetch_row($d)){ echo $line[2]."<a href='cart_action.php?act=del&item=".$number."'>[x]</a><p>"; } } } } } } # $result = ''; for($i=1;$i<=$c;$i++){ foreach ($cc as $number) { if(in_array($number,$cc)){ if($number == $i){ if(!empty($_SESSION['item_id'.$number])){ $sql = "SELECT * FROM `".$_SESSION['tab_'.$number]."` WHERE cid=".$_SESSION['item_id'.$number]; $d = mysql_query($sql); while($line = mysql_fetch_row($d)){ $result.= $line[2]." "; } } } } } } $_SESSION['msg'] = $result; # } ?> <form method='post' action='cart_action.php?act=send'> <table width='100%' border='0' cellspacing='0' cellpadding='3'> <tr> <td width='150'>Ваше имя</td> <td><input name='fio' type='text'></td> </tr> <tr> <td>Ваш телефон:</td> <td><input name='phone' type='text'></td> </tr> <tr> <td>Ваше эл.адрес:</td> <td><input name='email' type='text'></td> </tr> <tr> <td> </td> <td><input name='send' type='submit' value='Отправить'></td> </tr> </table> </form> <body> </body> </html> и PHP: #index.php <? session_start(); mysql_connect("localhost","root",""); mysql_select_db('test_promo'); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> <title>Untitled Document</title> </head> <a href=cart.php>Просмотреть добавленное</a><p> <ol> <? if(isset($_GET['tab'])){ switch($_GET['tab']){ case'p100': $sql = "SELECT * FROM `p100` LIMIT 0, 30"; break; case'p200': $sql = "SELECT * FROM `p200` LIMIT 0, 30"; break; } } if(!isset($_GET['show'])){$_GET['show'] = 'page';} switch($_GET['show']){ case'catalogue': $d = mysql_query($sql); while($line = mysql_fetch_row($d)){ echo "<li>".$line[2]."<a href='cart_action.php?act=add&tab=".$_GET['tab']."&id=".$line[0]."&name=".$line[2]."'>добавить</a><p>"; } break; case'page': echo "<a href='?show=catalogue&tab=p100'>Каталог1</a><p>"; echo "<a href='?show=catalogue&tab=p200'>Каталог2</a><p>"; $sql = "SELECT * FROM `pages` WHERE `id`=1"; $d = mysql_query($sql); while($line = mysql_fetch_row($d)){ echo $line[3]."<p>".$line[5]; } } ?> </ol><body> </body> </html> и PHP: <? #cart_action.php session_start(); if($_GET['act']=="add"){ //включаем счетчик if(!isset($_SESSION['c'])){$_SESSION['c']=0;} $c=intval($_SESSION['c']); ++$c; $_SESSION['c']=$c; ///////////////////////////////////////////////////////////////////*/ $_SESSION['item_id'.$c] = $_GET['id']; $_SESSION['name_id'.$c] = $_GET['name']; $_SESSION['tab_'.$c] = $_GET['tab']; #echo "Наименование <b>".$_SESSION['name_id'.$c]."</b> с id равным <b>".$_SESSION['item_id'.$c]."</b> было добавлено <p> последнее число - ".$c; header("Location: index.php"); } if($_GET['act']=="del"){ $item = $_GET['item']; #echo "Наименование <b>".$_SESSION['name_id'.$item]."</b> с id равным <b>".$_SESSION['item_id'.$item]."</b> было удалено"; unset($_SESSION['item_id'.$item]); unset($_SESSION['name_id'.$item]); header("Location: cart.php"); } if($_GET['act']=="send"){ $to = "root"; $subj = "Отправка заказа"; #$from = $_POST['fio']; #$phone = $_POST['phone']; #$email = $_POST['email']; /*$msg = $_SESSION['msg']" Заказчик - $from Телефон - $phone Эл.Адрес - $email "*/; # $msg.= $_SESSION['msg']; if(mail($to,$subj,$msg)){ echo "Письмо отправлено <p>; } } ?>