网站首页 > 文章中心 > 其它

php购物商城数据表设计

作者:小编 更新时间:2023-09-13 14:51:48 浏览量:332人看过

购物网站数据库设计

要这样,这样你会有无数多的表,而且以后新的一个产品时候非常麻烦,如果要属于新的类别,而且还会因为避免数据库太复杂而使得许多不同类的产品归在一个类.而且你的程序很麻烦,要为每个类编写不同程序,因为数据表名不同.

应该用下面的办法,主要使用四个表存储所有类别的商品:

第第一段:类别名称表,字段有

类别ID,类别名称

①. 电脑

第第二段:类别属性表,字段有:

类别ID,属性ID,属性名称

①. 1 CPU

第第三段:商品名称表,字段有:

商品ID,类别ID

①. 1

第第四段:商品属性表,字段有:

商品ID,属性ID,属性值

这样定义的数据库结构,可以包含任何商品,一般不会改变,那么程序也就无需改变,定义新的产品、或者修改现有商品只需要在程序界面有操作员点点鼠标.

PHPI做电子商务系统,那个购物车怎么建表啊?

在数据库里面用表(ShopingCart)

表有几个基本字段

CartId 购物车ID(唯一)

Id 商品的ID(唯一)

Qty 用户购买商品的数量

CreateDate 购物车创建时间

此表的字段CartId是区分不同用户的购物车的ID,要是登陆用户,你可以在表中存放此登陆用户的登陆名的ID,要是未登陆用户使用购物车,

如果是非登陆用户

Php商品图片数量不固定,怎么设计表单跟数据库

①.、商品表建立商品基本信息主表CREATETABLEproduc.

php如何写商城

用php开发一个网上商城系统其实和大多数用php开发其他的系统,或者用其他的语言开发一个系统的流程是一样的.第一,在开发网上商城系统之前,得做好网上商城系统的需求分析.做好网上商城系统的需求分析对一个系统来说可谓是至关重要,需求分析指的是你到底要做一个怎样的网上商城系统,这个网上商城系统有什么功能,你要用这个网上商城系统做什么.说白了需求分析就是决定你什么的意思.第二,就要进入到网上商城系统项目分析的流程了.网上商城系统的需求分析解决了做什么的问题,网上商城系统的项目分析解决怎么做的问题.第三,进行完网上商城系统的项目分析后,就进入到了人员的分工流程上来了.我们确定了怎么做,就要确定那些人做的问题.网上商城系统人员分工就是解决每个人做什么的问题.第四,进行完人员分工的工作后就要进行网上商城系统代码的编写流程了.这个流程就是要求分得了工作任务的人员在规定的时间内把自己的工作完成.第五,代码编写完成后,就要进行系统测试流程了.我们的系统要进过各种各样的测试,系统流畅性测试,系统稳定性测试,系统安全性测试,只有通过了系统的测试,网上商城系统才可以交付用户使用.第六,做完了系统测试之后,就可以交付给用户使用了.

请教关于PHP购物车代码的数据库表和字段

PHP Code

h1Products/h1

php

//current URL of the Page. cart_update.php redirects back to this URL

$results = $mysqli-query("SELECT * FROM cart ORDER BY id ASC");

if ($results) {

//fetch results set as object and output HTML

while($obj = $results-fetch_object())

{

echo 'form method="post" action="cart_update.php"';

echo 'Price '.$currency.$obj-price.' | ';

echo 'button class="add_to_cart"Add To Cart/button';

echo 'input type="hidden" name="product_code" value="'.$obj-product_code.'" /';

echo 'input type="hidden" name="type" value="add" /';

echo 'input type="hidden" name="return_url" value="'.$current_url.'" /';

echo '/form';

}

if(isset($_SESSION["products"]))

$total = 0;

echo 'ol';

foreach ($_SESSION["products"] as $cart_itm)

echo 'li class="cart-itm"';

echo 'span class="remove-itm"a href="cart_update.php?removep='.$cart_itm["code"].'return_url='.$current_url.'"X/a/span';

echo '/li';

$subtotal = ($cart_itm["price"]*$cart_itm["qty"]);

$total = ($total ◆ $subtotal);

echo '/ol';

echo 'span class="check-out-txt"strongTotal : '.$currency.$total.'/strong a href="view_cart.php"Check-out!/a/span';

echo 'span class="empty-cart"a href="cart_update.php?emptycart=1return_url='.$current_url.'"Empty Cart/a/span';

}else{

echo 'Your Cart is empty';

cart_update.php

session_start();

include_once("config.php");

//empty cart by distroying current session

if(isset($_GET["emptycart"]) $_GET["emptycart"]==1)

session_destroy();

header('Location:'.$return_url);

//add item in shopping cart

if(isset($_POST["type"]) $_POST["type"]=='add')

$product_code = filter_var($_POST["product_code"], FILTER_SANITIZE_STRING); //product code

$product_qty = filter_var($_POST["product_qty"], FILTER_SANITIZE_NUMBER_INT); //product code

//limit quantity for single product

if($product_qty 10){

//MySqli query - get details of item from db using product code

$results = $mysqli-query("SELECT product_name,price FROM cart WHERE product_code='$product_code' LIMIT 1");

$obj = $results-fetch_object();

if ($results) { //we have the product info

//prepare array for the session variable

$new_product = array(array('name'=$obj-product_name, 'code'=$product_code, 'qty'=$product_qty, 'price'=$obj-price));

if(isset($_SESSION["products"])) //if we have the session

$found = false; //set found item to false

foreach ($_SESSION["products"] as $cart_itm) //loop through session array

if($cart_itm["code"] == $product_code){ //the item exist in array

$product[] = array('name'=$cart_itm["name"], 'code'=$cart_itm["code"], 'qty'=$product_qty, 'price'=$cart_itm["price"]);

$found = true;

//item doesn't exist in the list, just retrive old info and prepare array for session var

$product[] = array('name'=$cart_itm["name"], 'code'=$cart_itm["code"], 'qty'=$cart_itm["qty"], 'price'=$cart_itm["price"]);

if($found == false) //we didn't find item in array

//add new user item in array

$_SESSION["products"] = array_merge($product, $new_product);

//found user item in array list, and increased the quantity

$_SESSION["products"] = $product;

//create a new session var if does not exist

$_SESSION["products"] = $new_product;

//redirect back to original page

//remove item from shopping cart

if(isset($_GET["removep"]) isset($_GET["return_url"]) isset($_SESSION["products"]))

$product_code = $_GET["removep"]; //get the product code to remove

foreach ($_SESSION["products"] as $cart_itm) //loop through session array var

if($cart_itm["code"]!=$product_code){ //item does,t exist in the list

//create a new product list for cart

view_cart.php

echo 'form method="post" action="paypal-express-checkout/process.php"';

echo 'ul';

$cart_items = 0;

$product_code = $cart_itm["code"];

$results = $mysqli-query("SELECT product_name,product_desc, price FROM cart WHERE product_code='$product_code' LIMIT 1");

echo 'input type="hidden" name="item_name['.$cart_items.']" value="'.$obj-product_name.'" /';

echo 'input type="hidden" name="item_code['.$cart_items.']" value="'.$product_code.'" /';

echo 'input type="hidden" name="item_desc['.$cart_items.']" value="'.$obj-product_desc.'" /';

echo 'input type="hidden" name="item_qty['.$cart_items.']" value="'.$cart_itm["qty"].'" /';

$cart_items ◆◆;

echo '/ul';

echo 'span class="check-out-txt"';

echo 'strongTotal : '.$currency.$total.'/strong ';

echo '/span';

以上就是土嘎嘎小编为大家整理的php购物商城数据表设计相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章