View Single Post

  #9 (permalink)  
Old 21-11-2008, 03:53 PM
louie's Avatar
louie louie is offline
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,323
Nominated 7 Times in 5 Posts
Nominated TOTW/F/M Award(s): 2
Thanks: 0
Thanked 1 Time in 1 Post
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

Something to get you rolling:

$sql = "";
$oid = "someid"; //don't know what that is so I gave it a value
$id = !empty($_GET['id']) ? preg_replace("#[^0-9]#","",$_GET['id']) : "111";
$name = !empty($_GET['name']) ? preg_replace("#[^0-9a-zA-Z\- ]#","",$_GET['name']) : "name";
$price = !empty($_GET['price']) ? preg_replace("#[^0-9]#","",$_GET['price']) : "999";
$supplier = !empty($_GET['supplier']) ? preg_replace("#[^0-9a-zA-Z\- ]#","",$_GET['supplier']) : "SUPPLIER";
$category = !empty($_GET['category']) ? preg_replace("#[^0-9a-zA-Z\- ]#","",$_GET['category']) : "CATEGORY";

$basketArray = array();
$basketArray['id'] = $id;
$basketArray['name'] = $name;
$basketArray['price'] = $price;
$basketArray['supplier'] = $supplier;
$basketArray['category'] = $category;
$basketArray['qty'] = 1;
//$price = $_GET['price'];
$subtotal = !empty($_SESSION['subtotal']) ? $_SESSION['subtotal'] : "0";
$found = false;
//print_r($basketArray);
if(!empty($_SESSION['basket'])) {
foreach($_SESSION['basket'] as $key) {
foreach($key as $x=>$y){
echo $x."-".$y."<br />";
if($y == $id) {
$found = true;
echo "<h1>found</h1>";
break;
}
}
}
}
if(!$found) {
$subtotal = ($subtotal + $price);
$_SESSION['subtotal'] = $subtotal;
$_SESSION['basket'][] = $basketArray;
//insert data to DB
$sql = "INSERT INTO orders VALUES(0,'".$id."','".$oid."','".$name."','".$pric e."','".$supplier."','".$category."')";
}else{
//update quantity
$sql = "UPDATE orders.....";
}
//header("Location: foodItems.php?category=".$category."" );
//exit();
//print_r($_SESSION['basket']);

if($sql != ""){
echo "<h1>".$sql."</h1>";
//$result = mysql_query($sql, $connection)
//or die("MySQL Error: ".mysql_error());
}
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Car Parts & Accessories Car Parts
:. Cars Ireland Cars Ireland
:. I Have 2 Find It Directory SEF Directory
Reply With Quote