⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 buy.php

📁 这个版本只是修正了一些BUG
💻 PHP
字号:
<?php
/***********************************************
    	buy.php  

	Version  : 1.2
	Author   : Tracemouse (tracemouse@msn.com)
	Copyright: www.vitci.com
	Writed   : 2003/09/20
	Modified : 2004/04/13
************************************************/
require "./include/base.php";
$nav .=SEPARATER.$language['buy'];

if (!$islogin)
{
	include template('login');
	exit;
}

$username=$_login_user;
if($action=='buy')
{
	$productid=intval($productid);
	$query = $db->query("select count(*) from $table_products where productid=$productid",1);
	$num = $db->result($query,0);
	if($num == 0)		showmessage('product not found');
	$query=$db->query("select count(*) from $table_basket where username='$username' and productid=$productid and oid='picking'");
  	$num=$db->result($query,0);
  	if($num > 0) 		showmessage('buy_already');
  	$query=$db->query("select * from $table_products where productid=$productid");
  	if($dbq_rec = $db->fetch_array($query))
  	{
   		$price=$dbq_rec['ourprice'];
  	}
  	$sqlstr="insert into $table_basket(username,productid,amount,price,oid)  values('$username',$productid,1,$price,'picking')";
  	if($query=$db->query($sqlstr)) 		showmessage('buy_success','basket.php');
  	else							  	showmessage('db_err');
}
elseif($action=='buyall')
{
	$sqlstr="select * from $table_favorite where username='$username' order by fid";
	$query=$db->query($sqlstr);
	while($dbq_rec=$db->fetch_array($query))
	{
		$productid=$dbq_rec['productid'];
		$query=$db->query("select count(*) from $table_basket where username='$username' and productid=$productid and oid='picking'");
  		$num=$db->result($query,0);
  		if($num == 0)
  		{
  			$query=$db->query("select * from $table_products where productid=$productid");
  			if($dbq_rec = $db->fetch_array($query))
  			{
   				$price=$dbq_rec['ourprice'];
  			}
  			$sqlstr="insert into $table_basket(username,productid,amount,price,oid)  values('$username',$productid,1,$price,'picking')";
  			$query=$db->query($sqlstr,1); 		 
		}
	}
	$query=$db->query("delete from $table_favorite where username='$username'",1);
	showmessage('buy_success','basket.php');
}

include template('myshop');
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -