3 Replies - 6150 Views - Last Post: 08 January 2009 - 12:15 AM Rate Topic: -----

#1 ch aqeel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 31-December 08

PHP Shopping Cart

Post icon  Posted 31 December 2008 - 10:24 PM

Hello Friends
Aqeel Here. I want a shopping cart in php for the submission of my finall assignment . In which we use object oriented approach and no frame work of php.
if anybidy wants to help me then plz mail me.
{REMOVED}
Thanx
Regards
Aqeel Chaudary
Is This A Good Question/Topic? 0

Replies To: PHP Shopping Cart

#2 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5296
  • View blog
  • Posts: 27,178
  • Joined: 10-May 07

Re: PHP Shopping Cart

Posted 01 January 2009 - 09:12 PM

View Postch aqeel, on 31 Dec, 2008 - 11:24 PM, said:

if anybidy wants to help me then plz mail me.


You'll have a much better response if you post detailed questions in the PHP topic. Usually someone with less than 10 posts that asks for help on a major project, well... not to many people are looking to do work for someone else for nothing.

Best of luck with your project.
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: PHP Shopping Cart

Posted 01 January 2009 - 09:20 PM

I'll go ahead and move this to the PHP forum, but be aware you're more than likely not going to get the responses you're looking for

[rules][/rules]
Was This Post Helpful? 1
  • +
  • -

#4 adnan15110  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-December 08

Re: PHP Shopping Cart

Posted 08 January 2009 - 12:15 AM

View Postch aqeel, on 31 Dec, 2008 - 09:24 PM, said:

Hello Friends
Aqeel Here. I want a shopping cart in php for the submission of my finall assignment . In which we use object oriented approach and no frame work of php.
if anybidy wants to help me then plz mail me.
{REMOVED}
Thanx
Regards
Aqeel Chaudary


Create A table in database
CREATE TABLE `cart` (
  `sess_id` varchar(255) collate latin1_general_ci NOT NULL,
  `product_id` int(10) NOT NULL,
  `quantity` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

then

use this php function(modify the query)
//////////////////////////////  add or show   //////////////////////////////////

function in_stock($product_id, $quantry, $type)
{
	$sess_id = session_id();
	
	if($type == "total")
	{
		$count_product = $quantry;
		$return_array[count_product] = $count_product;
	}
	else if($type == "add")
	{
		$count_product = select_data("quantity", "cart", "WHERE `sess_id` = '$sess_id' AND `product_id` = $product_id", "single_data") + $quantry;
		$return_array[count_product] = $count_product;
	}
	$stock = select_data("quantity", "product", "WHERE `id` = $product_id", "single_data");
	
	
	$return_array[stock] = $stock;	
	
	if($stock >= $count_product)
	{
		$return_array[status] = 1;
	}
	else
	{
		$return_array[status] = 0;
	}
	
	return $return_array;
}


//////////////////////////////  CART STATUS  //////////////////////////////////
		
function cart_status()
{
	$sess_id = session_id();
	
	$query = "SELECT * 
			  FROM `cart` 
			  WHERE `sess_id` = '$sess_id'";
	
	//echo $query."<br>";
				
	$i=0;
		
	$result = mysql_query($query);
	
	if(mysql_num_rows($result)!=0)
	{
		while ($data = mysql_fetch_array($result))
		{
			$product_price = select_data("price", "product", "WHERE `id` = $data[product_id]", "single_data");
			$gross_price = $product_price * $data[quantity];
			
			//CART PRICE
			$return_array[total] += $gross_price;
	
			//QUANTITY
			$return_array[quantity] += $data[quantity];
		}
		return $return_array;	
	}
}


////////////////////////////select data\\\\\\\\\\\\\\\\\\\\\\\\\

function select_data($fetch, $table, $where, $process)
{
	global $db_database, $tbl_prefix;
	
	$table = $tbl_prefix . $table;
	
	
	$query = "SELECT $fetch FROM `$table` $where";
	$result = mysql_query($query);
	
	//echo $query."<BR>";
	
	switch($process)
	{
		
		// SELECT SINGLE DATA OF TABLE [SINGLE VARIABLE]
		/*---------------------------------------------------------*/
		case "single_data":
		{
			$data = mysql_fetch_row($result);
			
			if(mysql_num_rows($result)==1)
				return $data[0];
			else
				return 0;
			break;
		}
				
	}//end of switch	
	
}


Use this function with some necessary modification

This post has been edited by adnan15110: 08 January 2009 - 12:24 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1