php 产品进销存管理系统开发实例教程(1/13)

 更新时间:2016年11月25日 16:28  点击:1787
本文章来给各位朋友讲一下php 产品进销存管理系统开发实例教程哦。我们先看看有那些功能

首页文件 index.html

<HTML>
<HEAD>
<TITLE> 产品进销存管理系统 </TITLE>
</HEAD>

<BODY>

<table border="0" width="100%" cellpadding="2" height="12">
<tr>
<td width="100%">
      <h2 align=center> 产品进销存管理系统</h2>
    </td>
</tr>
<tr>
<td width="100%" height="6">
        <p align="center">
  <a href="index.html"><font color="#008000">返回首页</font></a>
  <font color="#8EB4D9">|</font>
  <a href="reg.php"><font color="#008000">注册</font></a>
  <font color="#8EB4D9">|</font>
  <a href="login.php"><font color="#008000">登录</font></a>
        <font color="#8EB4D9">|</font>
  <a href="addcompany.php"><font color="#008000">添加厂商</font></a>
  <font color="#8EB4D9">|</font>
  <a href="addproduct.php"><font color="#008000">添加产品</font></a>
        <font color="#8EB4D9">|</font>
  <a href="buy.php"><font color="#008000">进货</font></a>
  <font color="#8EB4D9">|</font>
  <a href="sell.php"><font color="#008000">销售</font></a>
  <font color="#8EB4D9">|</font>
  <a href="browse.php"><font color="#008000">查看存货</font></a>
        <font color="#8EB4D9">|</font>
  <a href="logout.php"><font color="#008000">注销</font></a>
    </td>
</tr>
<tr><td height=30></td></tr>
<tr><td align=center>
      <h2><font color=blue >欢迎光临进销存管理系统!</font></h2>
</td></tr>
</table>
</BODY>
</HTML>

 

<?
  $HTTP_COOKIE_VARS["VisitTimes"]?($VisitTimes ++):($VisitTimes = 1);
  setcookie("VisitTimes",$VisitTimes,time()+31536000);
  echo "<b>欢迎你第<font color="#FF0000"> ".$VisitTimes.
  " </font>光临我的主页</b><br>n";
  ?>

cookie在WEB应用常常被用到,我们上面提供的这款php教程 cookie应用实例是一款在实例应用常用到的代码

php教程 生成word文档并下载代码
include("include/conn_mysql教程.php");
  $id=$_GET["id"];
  $sql="select * from  down where id=$id ";
  $result=mysql_query($sql);  
  $row=mysql_fetch_row($result);
  $file2=$row["upload"];
 
function downFile($sFilePath)
{
   if(file_exists($sFilePath)){
       $aFilePath=explode("/",str_replace("\","/",$sFilePath),$sFilePath);
       $sFileName=$aFilePath[count($aFilePath)-1];
       $nFileSize=filesize ($sFilePath);
       header ("Content-Disposition: attachment; filename=" .basename($sFileName) );
       header ("Content-Length: " . $nFileSize);
       header ("Content-type: application/octet-stream");
       mb_convert_encoding(readfile($sFilePath),"utf-8","GB2312");
   }
   else
   {
       echo("文件不存在!");
   }
}

downFile($file2);
/*
这个生成word生成文档程序是从mysql数据库教程读取数据保存文件再用header来发送给浏览器。
*/

本文章主要是一个php初学者写的原创的php日历控件 ,可以显示当前日期与今天是星期几,是否为闰年, 可自动选择上一年或下一年,月份日期也是一样的。

简单的php教程日历类控件代码实例
/*

*/
date_default_timezone_set("Etc/GMT-8");

class Calendar{

var $T = array();
var $datesOFmonth = array('1'=>'31','2'=>'28','3'=>'31','4'=>'30','5'=>'31','6'=>'30','7'=>'31','8'=>'31','9'=>'30','10'=>'31','11'=>'30','12'=>'31');
var $Y,$M,$D;

function set($time){
$this->T = getdate($time);
$this->Y = $this->T['year'];
$this->M = $this->T['mon'];
$this->D = date('d',$time);
}

function isRun(){
return ($this->Y%400==0 || ($this->Y%4==0 && $this->Y%100==0)) ? 1 : 0;
}

function first(){
$time = mktime(0,0,0,$this->M,1,$this->Y);
$time = getdate($time);
return $time['wday'];
}

function html(){
$isRun = $this->isRun();
$this->datesOFmonth[2] = $isRun==1 ? 29: 28;
$html .= "<table style='border:solid 1px black;'>n";
$html .= "<tr><th><a href=''>上一月</a></th><th colspan='5'>{$this->Y}年 {$this->M}月</th><th><a href=''>下一月</a></th><tr>n";
$html .= "<tr><td>星期天</td><td>星期一</td><td>星期二</td><td>星期三</td><td>星期四</td><td>星期五</td><td>星期六</td></tr>n";
$html .= "<tr>n";
$first = $this->first();
for($i=0; $i<$first; $i++){
$html .= "<td></td>";
}
$count = $this->datesOFmonth[$this->M]+$first;
for ($i=1; $i<= $this->datesOFmonth[$this->M]; $i++){
$style = $i==$this->D ? ' style="color:red;font-weight:bold;"' : '' ;
$html .= "<td align='center'{$style}>$i</td>";
if (($i==7%$first || ($i+$first)%7==0) && $i<$count){
$html .= "</tr>n<tr>";
}
}
$count = 7-$count%7;
if ($count<7){
for ($i=0; $i<$count; $i++){
$html .= "<td></td>";
}
}
$html .= "</tr>n";
$html .= "</table>n";
return $html;
}
}

$calendar = new Calendar();
$calendar->set(time());
echo $calendar->html();

这里我们为你提供个简单的php购物车代码哦,从增加购物产品与发生购买了,在商城开发中,这个功能是少不了的,我们不需要数据库,用了txt文本文件来操作用户购物的内容。

增加商品到购物车

 代码如下 复制代码

<?php
//
// add_item.php:
//  Add an item to the shopping cart.
//
session_start();
if (session_is_registered('cart')) {
    session_register('cart');
}

require 'lib.inc.php'; // LoadProducts()

LoadProducts(); // Load products in $master_products_list

// Make $curr_product global
$curr_product = array();

// Loop through all the products and pull up the product
// that we are interested in

 

foreach ($master_products_list as $prod_id => $product) {
    if (trim($prod_id) == trim($_GET[id])) {
        $curr_product = $product;
    }
}


// Register our session
//session_register('cart');
//if(session_is_registered('cart')) echo "已经注册";

 

if ($_POST[ordered]) {  // If they have chosen the product

    array_push($_SESSION[cart][products], array(trim($_POST[id]), $_POST[quantity]));
    $_SESSION[cart][num_items] += $_POST[quantity];
 
}
?>

<html>
<head>
    <title>
    <?php if ($_POST[ordered]) {  ?>
        已经添加 <?php echo $curr_product[name]; ?> 到您的购物篮
    <?php } else {  ?>
        添加 <?php echo $curr_product[name]; ?> 到您的购物篮
    <?php } ?>
    </title>
</head>
<body>
<?php if ($_POST[ordered]) {  ?>
    <h1><?php echo $curr_product[name]; ?>
        添加至购物篮成功</h1>

    <a href="cart.php">返回</a> 商品列表页面.
<?php }  else {  ?>
    <h1>添加 <?php echo $curr_product[name]; ?> 到您的购物篮</h1>

    <form action="<?php echo $PHP_SELF; ?>" method="post">
    商品名称: <?php echo $curr_product[name]; ?>
    <br>
    商品说明: <?php echo $curr_product[desc]; ?>
    <br>
    商品单价: RMB<?php echo $curr_product[price]; ?>
    <br>
    商品数量: <input type="text" size="7" name="quantity">
    <input type="hidden" name="id" value="<?php echo $_GET[id]; ?>">
    <input type="hidden" name="ordered" value="1">

    <input type="submit" value="添加至购物栏">
    </form>
<?php } ?>
</body>
</html>

查看购物车的商品

 代码如下 复制代码

<?php
//
// cart.php:  www.111cn.net
//
session_start();

require 'lib.inc.php';
//判断购物篮会话变量cart是否注册,不注册则注册cart变量
if (session_is_registered('cart')) {
    session_register('cart');
}


// 如果购物篮没有初始化,则初始化购物篮
if (!isset($_SESSION[cart][num_items])) {
    $_SESSION[cart] = array("num_items" => 0,
                  "products"  => array());
}


// From site_lib.inc, Loads the $master_products_list array
LoadProducts(); //载入物品列表
?>

<html>
<head>
    <title>演示会话跟踪的购物篮程序</title>
</head>

<body>

<h1>欢迎进入网上商店</h1>

<?php
if ($_SESSION[cart][num_items]) {  // If there is something to show
?>
<h2>当前在购物篮里的物品</h2>
<br>
<table border="2" cellpadding="5" cellspacing="2">
<tr>
    <th>
        商品名称
    </th>
    <th>
        商品说明
    </th>
    <th>
        单价
    </th>
    <th>
        数量
    </th>
    <th>&nbsp;
       
    </th>
</tr>
<?php
  
    // Loop through the products
    foreach ($_SESSION[cart][products] as $i => $product) {
        $product_id = $product[0];
        $quantity   = $product[1];

        $total += $quantity *
                  (double)$master_products_list[$product_id][price];
?>
<tr>
    <td>
        <?php echo $master_products_list[$product_id][name]; ?>
    </td>
    <td>
        <?php echo $master_products_list[$product_id][desc]; ?>
    </td>
    <td>
        <?php echo $master_products_list[$product_id][price]; ?>
    </td>
    <td>
        <form action="change_quant.php" method="post">
        <input type="hidden" name="id" value="<?php echo $i; ?>">
        <input type="text" size="3" name="quantity"
                value="<?php echo $quantity; ?>">
    </td>
    <td>
        <input type="submit" value="数量更改">
        </form>
    </td>
</tr>
<?php
    }
?>
<tr>
    <td colspan="2" ALIGN="right">
       <b>合计: </b>
    </td>
    <td colspan="2">
        RMB:<?php echo $total; ?>
    </td>
 <td>&nbsp;</td>
</tr>
</table>
<br>
<br>
<?php
}
?>

<h2>商店待出售的商品</h2>
<br>
<i>
    我们提供以下商品待售:
</i>
<br>
<table border="2" cellpadding="5" cellspacing="2">
<tr>
    <th>
        商品名称
    </th>
    <th>
        商品说明
    </th>
    <th>
        单价
    </th>
    <th>&nbsp;
       
    </th>
</tr>
<?php
    // Show all of the products
    foreach ($master_products_list as $product_id => $item) {
?>
<tr>
    <td>
        <?php echo $item[name]; ?>
    </td>
    <td>
        <?php echo $item[desc]; ?>
    </td>
    <td>
        $<?php echo $item[price]; ?>
    </td>
    <td>
        <a href="add_item.php?id=<?php echo $product_id; ?>">
            添加至购物篮
        </a>
    </td>
</tr>
<?php
    }

?>
</table>

修改购物车的数量

 代码如下 复制代码

<?php
//
// change_quant.php:
//   Change the quantity of an item in the shopping cart.
//
session_start();
if (session_is_registered('cart')) {
    session_register('cart');
}

// Typecast to int, making sure we access the
// right element below
$i = (int)$_POST[id];

// Save the old number of products for display
// and arithmetic
$old_num = $_SESSION[cart][products][$i][1];

if ($_POST[quantity]) {
    $_SESSION[cart][products][$i][1] = $_POST[quantity]; //change the quantity
} else {
    unset($_SESSION[cart][products][$i]); // Send the product into oblivion
}

// Update the number of items
$_SESSION[cart][num_items] = ($old_num >$_POST[quantity]) ?
                   $_SESSION[cart][num_items] - ($old_num-$_POST[quantity]) :
                   $_SESSION[cart][num_items] + ($_POST[quantity]-$old_num);
?>

<html>
<head>
    <title>
        数量修改
    </title>
</head>
<body>
    <h1> 将数量: <?php echo $old_num; ?> 更改为
         <?php echo $_POST[quantity]; ?></h1>
    <a href="cart.php">返回</a> 商品列表页面.
</body>
</html>

功能页面,用户把购物车里面的内容保存到txt数据库

 代码如下 复制代码

<?php
//物品数组
$master_products_list = array();


//载入物品数据函数
function LoadProducts() {
    global $master_products_list;
    $filename = 'products.txt';

    $fp = @fopen($filename, "r")
        or die("打开 $filename 文件失败");
    @flock($fp, 1)
        or die("锁定 $filename 文件失败");

    //读取文件内容
    while ($line = fgets($fp, 1024)) {
        list($id, $name, $desc, $price) = explode('|', $line); //读取每行数据,数据以| 格开
        $id = trim($id); //去掉首尾特殊符号
        $master_products_list[$id] = array("name" =>  $name, //名称
                                           "desc" =>  $desc, //说明
                                           "price" => $price); //单价
    }

    @fclose($fp)  //关闭文件
        or die("关闭 $filename 文件失败");
}
?>

很简单,我们只用了4个文件就实现用php 做好购物车功能哦,好了这只是一款简单的php购物车代码更复杂的需要考虑更多更好。

[!--infotagslink--]

相关文章

  • python实现学生通讯录管理系统

    这篇文章主要为大家详细介绍了python实现学生通讯录管理系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-02-25
  • 护卫神 主机管理系统使用说明(MSSQL管理)

    护卫神·主机管理系统该版本支持在Windows Server 200320082012,含32位和64位,直接开设配置WEB站、FTP站,以及SQL Server和MySQL,是您开设和管理虚拟主机的绝好帮手。但是对于新用户可能在使用上有一些困难,因此请仔细阅读如下说明文档...2016-01-27
  • 深入C# 内存管理以及优化的方法详解

    本篇文章是对C#中内存管理以及优化的方法进行了详细的分析介绍,需要的朋友参考下...2020-06-25
  • 详解swift中xcworkspace多项目管理

    给大家详细讲解了IOS开发中swift语言xcworkspace多项目管理的方法和介绍,一起参考一下。...2020-06-30
  • js实现车辆管理系统

    这篇文章主要为大家详细介绍了js实现车辆管理系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2020-08-26
  • php需登录的文件上传管理系统

    本文给大家介绍一个不错的需要登录的php 文件上传管理系统,功能简单有需要了解的同学可参考。 代码如下<&#63;php$admin_pw="admin";//管理密码$uploaddir="upload";//上传目录session_start();if($_GET['action']=="g...2015-10-30
  • thinkphp自定义权限管理之名称判断方法

    下面小编就为大家带来一篇thinkphp自定义权限管理之名称判断方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2017-04-03
  • C++学生信息管理系统

    这篇文章主要为大家想详细介绍了C++学生信息管理系统的实现代码,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2020-04-25
  • jQuery技巧之让任何组件都支持类似DOM的事件管理

    这篇文章主要介绍了jQuery技巧之让任何组件都支持类似DOM的事件管理 的相关资料,需要的朋友可以参考下...2016-04-06
  • C语言学生成绩管理系统小设计

    这篇文章主要为大家详细介绍了C语言学生成绩管理系统小设计,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2020-04-25
  • C#毕业设计之Winform零压健身房管理系统

    本文介绍了个人的《零压健身房管理系统(扁平化)》的基本流程和功能点的介绍,虚心接受各位的意见,欢迎在提出宝贵的意见,大家一起探讨学习...2021-09-26
  • vue前端开发辅助函数状态管理详解示例

    vue的应用状态管理提供了mapState、mapGetters、mapMutations、mapActions四个辅助函数,所谓的辅助函数分别对State、Getters、Mutations、Actions在完成状态的使用进行简化...2021-10-10
  • 如何管理Vue中的缓存页面

    这篇文章主要介绍了如何管理Vue中的缓存页面,帮助大家更好的理解和学习使用vue框架,感兴趣的朋友可以了解下...2021-02-06
  • C#实现微信公众号会员卡管理的示例代码

    这篇文章主要介绍了C#实现微信公众号会员卡管理的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-06-25
  • C++顺序表实现图书管理系统

    这篇文章主要为大家详细介绍了C++顺序表实现图书管理系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-10-13
  • 基于python实现银行管理系统

    这篇文章主要介绍了基于python实现银行管理系统,文中有非常详细的代码示例,对正在学习python项目制作的小伙伴们有很好的帮助,需要的朋友可以参考下...2021-04-19
  • 40行代码把Vue3的响应式集成进React做状态管理

    这篇文章主要介绍了40行代码把Vue3的响应式集成进React做状态管理,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-05-20
  • 详解Java如何使用集合来实现一个客户信息管理系统

    读万卷书不如行万里路,只学书上的理论是远远不够的,只有在实战中才能获得能力的提升,本篇文章手把手带你用Java 集合实现一个客户信息管理系统,大家可以在过程中查缺补漏,提升水平...2021-11-11
  • [原创]php+ajax实现模拟Win文件管理系统五

    [原创]php+ajax实现模拟Win文件管理系统 // 本教程由本站原创,转载请注明来处 作者:www.111cn.net 邮箱:drise@163.com QQ:271728967 // 就是deldir()函数了这个函数的...2016-11-25
  • jQuery实现B2B网站后台管理系统侧导航

    这篇文章主要介绍了jQuery实现B2B网站后台管理系统侧导航,文中示例代码非常详细,帮助大家更好的理解和学习,感兴趣的朋友可以了解下...2020-07-09