php 产品进销存管理系统开发实例教程

本系统能够录入标题、内容、图片、相关软件,彰显时会遵照是或不是有有图片和相关软件来判断是不是出示该项内容,展开页面显示的是最新的一片小说,点击目录会展现早先的稿子。
    创设channelimages和channelsoft目录,并把权力设为777。
*********************************
news表结构
*********************************
# Host: localhost Database : yourdb
# ——————————————————–

首页文件 index.html

#
# Table structure for table ‘yourtable’
#

<HTML>
<HEAD>
<TITLE> 付加物进销存管理种类 </TITLE>
</HEAD>

CREATE TABLE news(
   id int(11) DEFAULT ‘0’ NOT NULL auto_increment,
   kind varchar(16),
   title varchar(60),
   content text,
   pic varchar(30),
   timer datetime DEFAULT ‘0000-00-00 00:00:00’ NOT NULL,
   soft varchar(30),
   PRIMARY KEY (id),
   KEY timer (timer)
);

<BODY>

*********************************
情报录入文件:insert.htm
*********************************
<html>
<head>
<title>音信录入</title>
<meta http-equiv=”Content-Type” content=”text/html;
charset=gb2312″>
</head>
<body bgcolor=”#FFFFFF”>
<form name=”form1″ enctype=”multipart/form-data” action=”insert.php”
method=”post” >
  <table width=”81%” border=”0″ cellspacing=”2″ cellpadding=”0″
align=”center”>
    <tr>  
      <td width=”11%” align=”right” bgcolor=”#CC0000″><font
color=”#FFFFFF”>标题:</font></td>
      <td bgcolor=”#E7E7E7″>  
        <input type=”text” name=”title” size=”60″>
      </td>
    </tr>
    <tr>  
      <td align=”right” bgcolor=”#CC0000″><font
color=”#FFFFFF”>类别:</font></td>
      <td bgcolor=”#E7E7E7″>  
        <input type=”radio” name=”kind” value=”类型1″>
        类型1  
        <input type=”radio” name=”kind” value=”类型2″>
        类型2
        <input type=”radio” name=”kind” value=”类型3″>
        类型3
        <input type=”radio” name=”kind” value=”类型4″>
        类型4</td>
    </tr>
    <tr>  
      <td width=”11%” align=”right” bgcolor=”#CC0000″><font
color=”#FFFFFF”>内容:</font></td>
      <td bgcolor=”#E7E7E7″>  
        <textarea name=”content” cols=”60″
rows=”10″></textarea>
      </td>
    </tr>
    <tr>  
      <td width=”11%” align=”right” bgcolor=”#CC0000″><font
color=”#FFFFFF”>图片:</font></td>
      <td bgcolor=”#E7E7E7″>  
        <input type=”file” name=”pic” size=”60″>
      </td>
    </tr>
    <tr>  
      <td width=”11%” align=”right” bgcolor=”#CC0000″><font
color=”#FFFFFF”>软件:</font></td>
      <td bgcolor=”#E7E7E7″>  
        <input type=”file” name=”soft” size=”60″>
      </td>
    </tr>
    <tr>  
      <td width=”11%” align=”right”
bgcolor=”#CC0000″> </td>
      <td bgcolor=”#E7E7E7″>  
        <div align=”center”>  
          <input type=”submit” name=”Submit” value=”提 交”>
        </div>
      </td>
    </tr>
  </table>
</form>
</body>  
</html>  
*********************************
end of insert.htm
*********************************

<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>

*********************************
insert.php
*********************************
<?
$day=date(“md”);
If($pic != “none”){
$picname=$day.$pic_name;
copy($pic,”channelimages/$picname”);
unlink($pic);
}
If($soft!= “none”){
copy($soft,”channelsoft/$soft_name”);
unlink($soft);
}
$dbh =  mysql_connect(‘localhost’,’uesrname’,’passward’);
mysql_select_db(‘yourtable’);  
$dat=date(“Y-m-d h:i:s”);
$query=”insert into news(title,kind,content,pic,timer,soft)
values(‘$title’,’$kind’,’$content’,’$picname’,now(),’$soft_name’)”;
$res = mysql_query($query,$dbh);  

 

$err = mysql_error();
if($err){echo $err;exit();}
echo “<p></p><p align=center>”;
echo
“<body><h2>录入成功</h2></body></p>”;
?>
*********************************
end of insert.php
*********************************

 

*********************************
资源音讯突显文件:news.php
*********************************
<html>
<head>
<title>显示等级次序1</title>
<meta http-equiv=”目录项目” content=”文本/html; 字符集=gb2312″>
</head>
<body bgcolor=”#FFFFFF”>
<?
$db=mysql_connect(“localhost”,”username”,”passward”);
mysql_select_db(“yourtable”,$db);
$result=mysql_query(“select id,title from news where kind=’类型1′ order
by timer desc”);
for($a=0;$a<10;$a++)
{if(!($ahrow=mysql_fetch_row($result)))break;
$id=mysql_result($result,$a,”id”);
$title=mysql_result($result,$a,”title”);
echo “<a
href=news.php?id=”.$id.”>”.$title.”</a><br>”;
}
if (!isset($id)) $id=mysql_result($result1,0,”id”);
$result=mysql_query(“select * from news where id=$id order by timer
desc”);
$rows=mysql_fetch_row($result);
echo “<br><center><font color=ff0000>”;
print $rows[2];
echo “</font><br>$rows[5]</center>”;
if (strlen($rows[4])>0) echo “<p><img
src=channelimages/$rows[4] align=right>”;
echo str_replace(“r”,”<br>”,str_replace(”
“,” “,$rows[3]));
if (strlen($rows[6])>0) echo “</p><p align=right><a
href=channelsoft/$rows[6]>>>点击下载</a></p>”;
?>
</body>
</html>
*********************************
end of news.php
*********************************

头部.head.php

【本文版权归小编与奥索网合作具有,如需转发,请表明作者及出处】    

 

<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=10></td></tr>
</table>

 

 

数据库教程连波兰语件dbconnect.php

 

<?php
$conn=mysql教程_connect(“localhost”,”phpdb”,”phpdb”)
        or die(“不能够三番五次数据库服务器: “.mysql_error());
mysql_select_db(“product”,$conn卡塔尔国 or die (“不能够接收数据库:
“.mysql_error());

?>
数据库构造:
product.sql

drop database if exists product;
create database product;
use product;

CREATE TABLE user (
   id int(3) NOT NULL auto_increment,
   name varchar(20) not null,
   password varchar(50) NOT NULL,
   tel varchar(20),
   regtime datetime not null,
   PRIMARY KEY (id)
);

CREATE TABLE company (
   id int(6) not null auto_increment,
   name varchar(100) NOT NULL,
   address varchar(255) NOT NULL,
   tel varchar(100) NOT NULL,
   product varchar(255),
   linkman varchar(100) NOT NULL,
   addtime datetime NOT NULL,
   PRIMARY KEY (id)
);

 
create table product (
   productid int(6) not null auto_increment,
   companyid int(6) not null,
   name varchar(50) not null,
   brand varchar(50) not null,
   type varchar(50) not null,
   introduction text,
   other text,
   primary key (productid)
);

CREATE TABLE buylog(
   id int(6) NOT NULL auto_increment,
   user varchar(20) not null,
   productid int(6) not null,
   amount int(6) not null,
   buyprice decimal(9,2) DEFAULT ‘0.00’ NOT NULL,
   cost decimal(9,2) DEFAULT ‘0.00’ NOT NULL,
   ip varchar(20),
   buytime datetime NOT NULL,
   other text,
   primary KEY (id)
);

create table stock (
   productid int(6) not null,
   amount int(6) not null,
   buyprice decimal(9,2) DEFAULT ‘0.00’ NOT NULL,
   sellprice decimal(9,2) DEFAULT ‘0.00’ NOT NULL,
   cost decimal(9,2) DEFAULT ‘0.00’ NOT NULL,
   introduction text,
   buytime datetime not null,
   other text,
   primary key(productid, buyprice)
);

CREATE TABLE selllog(
   id int(10) NOT NULL auto_increment,
   user varchar(20) not null,
   productid int(6) not null,
   amount int(6) not null,
   buyprice decimal(9,2) DEFAULT ‘0.00’ NOT NULL,
   sellprice decimal(9,2) DEFAULT ‘0.00’ NOT NULL,
   cost decimal(9,2) DEFAULT ‘0.00’ NOT NULL,
   sellmoney decimal(9,2) DEFAULT ‘0.00’ NOT NULL,
   ip varchar(20),
   buytime datetime NOT NULL,
   selltime datetime not null,
   other text,
   primary KEY (id)
);

 

 

 

上面大家从顾客注册起头。展开index.html文件,点击注册,

注册reg.php

<?
include(“head.php”);
?>
<script
language=”javascript教程”>
    function checkreg()
    {    
  if (form1.name.value==””)
  {
   // 假如实际姓名字为空,则展现警示音讯
         alert(“真实姓名不能为空!”State of Qatar;
   form1.name.focus();
   return false;
     }
  if (form1.password.value==”” )
  {
   // 假如密码为空,则呈现警报音讯
         alert(“密码无法为空!”State of Qatar;
   form1.password.focus();
   return false;
     }
  if (form1.pwd.value==”” )
  {
   // 即使密码为空,则体现警示新闻
         alert(“确认密码无法为空!”卡塔尔;
   form1.pwd.focus();
   return false;
     }
  // 五次密码应平等
  if (form1.password.value!=form1.pwd.value &&
form1.password.value!=””)
  {
   alert(“两回密码不均等,请确认!”State of Qatar;
   form1.password.focus();
   return false;
  }  
  return true;

    } 
</script>

<html>
<body>

<form name=”form1″ method=”post” action=”regok.php”
enctype=’multipart/form-data’ onsubmit=”return checkreg()” >
  <table border=”0″ cellspacing=”1″ cellpadding=”3″
align=”center”>
    <tr>
      <th colspan=”2″><font size=”5″>用 户 注 册 界
面</font></th>
    </tr>   
    <tr>
      <td>真实姓名:</td>
      <td>
        <input type=”text” name=”name”>
    </tr>
    <tr>
      <td>密   码:</td>
      <td>
        <input type=”password” name=”password”>       
    </tr>
 <tr>
      <td>确认密码:</td>
      <td>
        <input type=”password” name=”pwd”>       
    </tr>
  <tr>
      <td>电   话:</td>
      <td>
        <input type=”text” name=”tel”>
    </tr>   
    <tr>
      <td  align=right >
        <input type=”submit” name=”Submit” value=”注 册”>
      </td>
      <td align=center>
        <input type=”reset” name=”Submit2″ value=”重 写”>
      </td>
    </tr>
  </table>
</form>

</body>
</html>

 

 

regok.php把多上卿存到mysql数据库

<?php
//初始化session
session_cache_expire(30);
session_start();
// 包括数据库连接文件和头文件
require (‘dbconnect.php’);
include (‘head.php’);
?>
<?php
// 获得网页的参数
$name=$_POST[‘name’];
$password=$_POST[‘password’];
$tel=$_POST[‘tel’];

// 加密密码
$password=md5($password);

// 取妥善前时刻和几日前
$now = date(“Y-m-d H:i:s”);

// 连接数据库,注册客商
$sql=”insert into user(name,password, tel, regtime)
values(‘$name’,’$password’,’$tel’,’$now’)”;
mysql_query($sql,$conn卡塔尔国 or die (“注册客商失利: “.mysql_error());

// 获得注册客商的电动id,今后使用此id才可登陆
$result=mysql_query(“select last_insert_id()”,$conn);
$re_arr=mysql_fetch_array($result);
$id=$re_arr[0];

// 注册成功,自动登陆,注册session变量
session_register(“user”);
$user=$id;
echo “<table align=center><tr><td
align=center>注册成功!</td></tr>”;
echo “<tr><td align=center><font
color=red>您的注册id是:”.$id;
echo
“,请你难忘,以往用此id登陆!</font></td></tr></table>”;

?>

 

 

好了客户注册成功了,大家就用刚刚登记的顾客名adsense,www.111cn.net登入吧。
登陆login.php页面代码

<?
//初始化session
session_cache_expire(30);
session_start();

// $_SESSION[‘UserName’] 无法用$UserName变量代替
if(isset($_SESSION[‘user’])) {
 //重定向到查看存货
 header(“Location:browse.php”);
 // 登入过的话,立时终止
   exit;
}
include (‘head.php’);
?>
<script language=”javascript”>
    function checklogin()
    {
      if ((login.username.value!=””) && (login.password.value!=””))
        // 倘若外号和密码均不为空,则赶回true
         return true
      else {
        // 假使小名或密码为空,则体现警报消息
         alert(“小名或密码不能够为空!”)
         return false
      }  
    }
</script>

<h1></h1>
<form action=”checkLogin.php” method=”post” name=”login”
onsubmit=”return checklogin()”>
<p align=”center”>顾客登陆</p>
<table align=”center” border=”0″>
 <tr>
  <th>
用户ID:
  </th>
  <th>
<input type=”text” name=”username”>
  </th>
 </tr>
 <tr>
  <th>
密 码:
  </th>
  <th>
<input type=”password” name=”password”>
  </th>
 </tr>
 <tr>
  <th colspan=”2″ align=”right”>
<input type=”submit” value=”登录”>
</form>
  </th>
 </tr>
</table>

 

登入成功就来增多商家

 

增添厂家addcompany.php

<?
//初始化session
session_cache_expire(30);
session_start();

// 若无登入,退出
if(!isset($_SESSION[‘user’])) {
   echo “<p align=center>”;
   echo “<font color=#FF0000 size=5><strong><big>”;
   echo “您还一向不登入,请<a href=’login.php’>登入</a>!”;
   echo “</big></strong></font></p>”;
   exit();
}
include (‘head.php’);
require (‘dbconnect.php’);
?>
<script language=”JavaScript”>

function select_change(){
 form1.submit();
}

</script>
<html>
<body>
<?php
// 纵然是交由前
if (($reg==””)&&($mod==””)) { ?>
<form name=”form1″ method=”post” action=”<?php echo $PHP_SELF
?>” >
  <table width=”60%” border=”0″ cellspacing=”1″ cellpadding=”3″
align=”center” bordercolor=”#8695AC”>
    <tr>
      <th colspan=”2″>厂 商 入 库 管 理</th>
    </tr>
    <tr align=”center”>
      <td colspan=”2″> </td>
    </tr>
    <tr align=”center”>
      <td colspan=”2″>
        <select name=”show” onChange=”select_change()”>
  <option value=”” selected>查看已入库的厂商音信</option>
<?php
$sql=”SELECT * FROM company”;
$result = mysql_query($sql,$conn卡塔尔国 or die(“数据库操作不当”卡塔尔(قطر‎;
while ($userrow=mysql_fetch_Array($result)){
 // 展现该厂商消息
 if ($show==$userrow[id]){
  $id=$userrow[id];
  $name=$userrow[name];
  $address=$userrow[address];
  $tel=$userrow[tel];
  $linkman=$userrow[linkman];
  $product=$userrow[product];
  echo “<option value=$userrow[id]
selected>$userrow[id]:$userrow[name]</option>”;
 }
 else {  
  echo “<option
value=$userrow[id]>$userrow[id]:$userrow[name]</option>”;
 }
}
?>
        </select>
      </td>
    </tr>
    <tr>
      <td width=”28%” align=”center” > </td>
      <td width=”72%”> </td>
    </tr>
 <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>厂商ID:</td>
   <?
  // 展现原记录
  if ($show!=””){
   echo “<td width=’72%’>$id</td>”;
   echo “<input type=hidden name=’old_id’ value=”.$id.”>”;
  }
  // 增加新记录
  else {
   echo “<td width=’72%’>自动生成</td>”;
  }
   ?>
     
    </tr>
 <tr>
      <td width=”28%” align=”center” > </td>
      <td width=”72%”> </td>
    </tr>
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>商家名称:</td>
      <td width=”72%”>
     <?
  if ($show!=””){
  ?>
        <input type=”text” name=”name” size=”60″ maxlength=”100″
value=”<?echo $name;?>”>
  <?}
  else {
  ?>
  <input type=”text” name=”name” size=”60″ maxlength=”100″ >
  <?}?>
      </td>
    </tr>
    <tr>
      <td width=”28%” align=”center” bgcolor=”#FFFFFF”
> </td>
      <td width=”72%”> </td>
    </tr>
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>厂商地址:</td>
      <td width=”72%”>
   <?
  if ($show!=””){
  ?>
        <input type=”text” name=”address” size=”60″ maxlength=”255″
value=”<?echo $address;?>”>
  <?}
  else {
  ?>
  <input type=”text” name=”address” size=”60″ maxlength=”255″ >
  <?}?>
      </td>
    </tr>
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#FFFFFF”> </td>
      <td width=”72%”> </td>
    </tr>
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>联系电话:</td>
      <td width=”72%”>
   <?
  if ($show!=””){
  ?>
        <input type=”text” name=”tel” size=”60″ maxlength=”100″
value=”<?echo $tel;?>”>
  <?}
  else {
  ?>
  <input type=”text” name=”tel” size=”60″ maxlength=”100″ >
  <?}?>
      </td>
    </tr>
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#FFFFFF”> </td>
      <td width=”72%”> </td>
    </tr>
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>联系人:</td>
      <td width=”72%”>
   <?
  if ($show!=””){
  ?>
        <input type=”text” name=”linkman” size=”60″ maxlength=”100″
value=”<?echo $linkman;?>”>
  <?}
  else {
  ?>
  <input type=”text” name=”linkman” size=”60″ maxlength=”100″ >
  <?}?>      
      </td>
    </tr>
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#FFFFFF”> </td>
      <td width=”72%”> </td>
    </tr>
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>主要产品:</td>
      <td width=”72%”>
   <?
  if ($show!=””){
  ?>
        <input type=”text” name=”product” size=”60″ maxlength=”255″
value=”<?echo $prodcut;?>”>
  <?}
  else {
  ?>
  <input type=”text” name=”product” size=”60″ maxlength=”100″ >
  <?}?> 
      </td>
    </tr>
    <tr align=”center”>
      <td colspan=”2″>        
  <?php
  // 增加新记录
  if ($show==””){
   echo “<input type=submit name=reg value=’登记入库’>”;
  }
  // 更正原记录
  else{
   echo “<input type=submit name=mod value=’完成修正’>”;
  }
  ?>
      </td>
    </tr>
  </table>
</form>
<?
}
// 如若是交由后甩卖
else {
 // 查看音信是还是不是填写完整
 if (($name==””)||($address==””)||($tel==””)||($linkman==””)){
  echo “<div align=center><font
color=red>音信尚未填写完整!</font></div>”;
  exit();
 }
// 如若是增多新记录
if ($reg){
 $result = mysql_query(“SELECT * FROM company WHERE
name=’$name'”,$conn);
 $userrow=mysql_fetch_array($result);
 if (!empty($userrow)) {
  echo “<div align=center><font
color=red>相近的商铺记录已经存在!</font></div>”;
  exit();
 }
 // 取稳妥前光阴和近些日子
 $now = date(“Y-m-d H:i:s”);
 $query = “insert into company(name, address, tel, linkman, product,
addtime) values (‘$name’,’$address’, ‘$tel’, ‘$linkman’, ‘$product’,
‘$now’)”;
 $res = mysql_query($query, $conn卡塔尔国 or die(“增多商家战败:
“.mysql_error());
}
elseif ($mod){
 // 取妥当前光阴和明天
 $now = date(“Y-m-d H:i:s”);
 $query = “update company set name=’$name’,address=’$address’,
tel=’$tel’, linkman=’$linkman’, product=’$product’ where
id=’$old_id'”;
 $res = mysql_query($query, $conn卡塔尔(قطر‎ or die(“修正厂家失利:
“.mysql_error());
}
?>
<p align=”center”> </p>
<p align=”center”> </p>
<p align=”center”><font
color=”red”>恭喜您!!</font><br>
  <br>
  登记达成!</p>
<p align=”center”><a href=”<?php echo $PHP_SELF
?>”>继续加多</a><br>
</p><?php } ?>

</body>
</html>

 

我们扩展三个www.111cn.net百货店的名称叫中华夏族民共和国WEB第一站,下边大家要为那一个商铺追加八个出品。如上面页面
丰富出品addproduct.php

 

<?
//初始化session
session_cache_expire(30);
session_start();

// 如果未有登陆,退出
if(!isset($_SESSION[‘user’])) {
   echo “<p align=center>”;
   echo “<font color=#FF0000 size=5><strong><big>”;
   echo “您还没曾登陆,请<a href=’login.php’>登陆</a>!”;
   echo “</big></strong></font></p>”;
   exit();
}
include (‘head.php’);
require (‘dbconnect.php’);
?>
<script language=”JavaScript”>

function company_change(){  
 //alert(document.form1.show.value);
 form1.submit();
}
function product_change(){
 form1.submit();
}

</script>
<html>
<body>
<?php
// 假设是提交前
if (($reg==””)&&($mod==””)) { ?>
<form name=”form1″ method=”post” action=”<?php echo $PHP_SELF
?>” >
  <table width=”60%” border=”0″ cellspacing=”1″ cellpadding=”3″
align=”center” bordercolor=”#8695AC”>
    <tr>
      <th colspan=”2″>产 品 入 库 管 理</th>
    </tr>
    <tr align=”center”>
      <td colspan=”2″> </td>
    </tr>
    <tr align=”center”>
      <td colspan=”2″>
   <table width=”60%”><tr><td align=center
width=”50%”>
        <select name=”show” onChange=”company_change()”>  
  <option value=”” selected>选取付加物所属商家</option>
<?php

$sql=”SELECT * FROM company”;
$result = mysql_query($sql,$conn卡塔尔 or die(“数据库操作不当”卡塔尔;
while ($userrow=mysql_fetch_Array($result)){
 // 展现该厂家音信
 if ($show==$userrow[id]){
  // 保存该厂家名字和id用于今后展现
  $companyid=$userrow[id];
  $companyname=$userrow[name];   
  echo “<option value=$userrow[id]
selected>$userrow[id]:$userrow[name]</option>”;
 }
 else {
  echo “<option
value=$userrow[id]>$userrow[id]:$userrow[name]</option>”;
 } 
}
?>
        </select>
  </td>
  <td align=center width=”50%”>
  <select name=”showpro” onChange=”product_change()”>  
  <option value=”” selected>选择产物</option>
<?php

$sqlp=”SELECT * FROM product where companyid=’$companyid'”;
$resultp = mysql_query($sqlp,$conn卡塔尔(قطر‎ or die(“数据库操作不当”卡塔尔;
while ($userrowp=mysql_fetch_Array($resultp)){
 // 显示该产物音讯
 if ($showpro==$userrowp[productid]){
  $productid=$userrowp[productid];
  $name=$userrowp[name];
  $brand=$userrowp[brand];
  $type=$userrowp[type];
  $intro=$userrowp[introduction];
  $other=$userrowp[other];
  echo “<option value=$userrowp[productid]
selected>$userrowp[productid]:$userrowp[name]</option>”;
 }
 else {
  echo “<option
value=$userrowp[productid]>$userrowp[productid]:$userrowp[name]</option>”;  
 } 
}
?>
  </select>
  </td></tr></table>
      </td>
    </tr>
    <tr>
      <td width=”28%” align=”center” > </td>
      <td width=”72%”> </td>
    </tr>
 <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>厂商ID:</td>
   <?
  // 呈现原记录
  if ($show!=””){
   echo “<td width=’72%’>$companyid:$companyname</td>”;
   echo “<input type=hidden name=’old_id’
value=”.$companyid.”>”;
  }
  // 增加新记录
  else {
   echo “<td width=’72%’>请接纳厂家</td>”;
   // 设置成品新闻变量为空   
   $name=””;
   $brand=””;
   $type=””;
   $intro=””;
   $other=””;
   $showpro=””;
  }
   ?>
     
    </tr>
 
 <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>产品ID:</td>
   <?
  // 显示原记录
  if ($showpro!=””){
   echo “<td width=’72%’>$productid</td>”;
   echo “<input type=hidden name=’old_pid’
value=”.$productid.”>”;
  }
  // 加多新记录
  else {
   echo “<td width=’72%’>自动生成</td>”;   
  }
   ?>     
    </tr>
 
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>成品名称:</td>
      <td width=”72%”>
   <?
  if ($showpro!=””){
  ?>
        <input type=”text” name=”name” size=”60″ maxlength=”100″
value=”<?echo $name;?>”>
  <?}
  else {?>
  <input type=”text” name=”name” size=”60″ maxlength=”100″>
  <?}?>
      </td>
    </tr>
   
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>产货品牌:</td>
      <td width=”72%”>
   <?
  if ($showpro!=””){
  ?>
        <input type=”text” name=”brand” size=”60″ maxlength=”255″
value=”<?echo $brand;?>”>
  <?}
  else {?>
  <input type=”text” name=”brand” size=”60″ maxlength=”255″ >
  <?}?>
      </td>
    </tr>
 
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>付加物品类:</td>
      <td width=”72%”>
   <?
  if ($showpro!=””){
  ?>
        <input type=”text” name=”type” size=”60″ maxlength=”255″
value=”<?echo $type;?>”>
  <?}
  else {?>
  <input type=”text” name=”type” size=”60″ maxlength=”255″>
  <?}?>

      </td>
    </tr>
   
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>产物介绍:</td>
      <td width=”72%”>
    <?
  if ($showpro!=””){
  ?>
        <textarea name=”intro” cols=”60″ rows=’5′><?echo
$intro;?></textarea>
  <?}
  else {?>
  <textarea name=”intro” cols=”60″ rows=’5′></textarea>
  <?}?>
  
      </td>
    </tr>
   
    <tr>
      <td width=”28%” align=”center” bgcolor=”#F0F8FF”>备   
注:</td>
      <td width=”72%”>
   <?
  if ($showpro!=””){
  ?>
        <textarea name=”other” cols=”60″ rows=’5′><?echo
$other;?></textarea>
  <?}
  else {?>
  <textarea name=”other” cols=”60″ rows=’5′></textarea>
  <?}?>
       
      </td>
    </tr>
   
    <tr align=”center”>
      <td colspan=”2″>        
  <?php
  // 增多新记录
  if ($showpro==””){
   echo “<input type=submit name=reg value=’登记入库’>”;
  }
  // 修改原记录
  else{
   echo “<input type=submit name=mod value=’完结改过’>”;
  }
  ?>
      </td>
    </tr>
  </table>
</form>
<?
}
// 纵然是提交后处理
else {
 // 查看音讯是不是填写完整
 if (($name==””)||($brand==””)||($type==””)||($old_id==””)){
  echo “<div align=center><font
color=red>消息尚未填写完整!</font></div>”;
  exit();
 }
// 假诺是增加新记录
if ($reg){
 $result = mysql_query(“SELECT * FROM product WHERE name=’$name’ and
companyid=’$old_id’ and brand=’$brand’ and type=’$type'”,$conn);
 $userrow=mysql_fetch_array($result);
 if (!empty($userrow)) {
  echo “<div align=center><font
color=red>该铺面包车型地铁同样付加物记录已经存在!</font></div>”;
  exit();
 }
 
 $query = “insert into product(companyid, name, brand, type,
introduction, other) values (‘$old_id’,’$name’,’$brand’, ‘$type’,
‘$intro’, ‘$other’)”;
 $res = mysql_query($query, $connState of Qatar or die(“增添付加物记录失败:
“.mysql_error());
}
elseif ($mod){
 $query = “insert into product(companyid, name, brand, type,
introduction, other) values (‘$old_id’,’$name’,’$brand’, ‘$type’,
‘$intro’, ‘$other’)”;
 $query = “update product set name=’$name’,brand=’$brand’, type=’$type’,
introduction=’$intro’, other=’$other’ where productid=’$old_pid'”;
 $res = mysql_query($query, $conn卡塔尔国 or die(“修正成品记录失利:
“.mysql_error());
}
?>
<p align=”center”> </p>
<p align=”center”> </p>
<p align=”center”><font
color=”red”>恭喜您!!</font><br>
  <br>
  登记达成!</p>
<p align=”center”><a href=”<?php echo $PHP_SELF
?>”>继续加多</a><br>
</p><?php } ?>

</body>
</html>

 

好了,商家与制品都扩充了,我们就来实例进货管理,如上边包车型客车买入处理页面。如笔者辈进www.111cn.net为地方的网址。
进货buy.php

 

<?
//初始化session
session_cache_expire(30);
session_start();

// 若无登陆,退出
if(!isset($_SESSION[‘user’])) {
   echo “<p align=center>”;
   echo “<font color=#FF0000 size=5><strong><big>”;
   echo “您还从未登入,请<a href=’login.php’>登入</a>!”;
   echo “</big></strong></font></p>”;
   exit();
}
include (‘head.php’);
require (‘dbconnect.php’);
?>
<script language=”JavaScript”>

function company_change(){
 form1.submit();
}
function product_change(){
 form1.submit();
}
</script>
<html>
<body>
<?php
// 要是是提交前
if ($buy==””) { ?>
<form name=”form1″ method=”post” action=”<?php echo $PHP_SELF
?>” >
  <table width=”60%” border=”0″ cellspacing=”1″ cellpadding=”3″
align=”center” bordercolor=”#8695AC”>
    <tr>
      <th colspan=”2″>进 货 登 记</th>
    </tr>
    <tr align=”center”>
      <td colspan=”2″> </td>
    </tr>
    <tr align=”center”>
      <td colspan=”2″>
   <table width=”60%”><tr><td align=center
width=”50%”>
        <select name=”show” onChange=”company_change()”>  
  <option value=”” selected>接收产物所属商家</option>
<?php

$sql=”SELECT * FROM company”;
$result = mysql_query($sql,$conn卡塔尔国 or die(“数据库操作不当”State of Qatar;
while ($userrow=mysql_fetch_Array($result)){
 // 展现该商家音信
 if ($show==$userrow[id]){
  // 保存该厂家名字和id用于未来展现
  $companyid=$userrow[id];
  $companyname=$userrow[name];   
  echo “<option value=$userrow[id]
selected>$userrow[id]:$userrow[name]</option>”;
 }
 else {
  echo “<option
value=$userrow[id]>$userrow[id]:$userrow[name]</option>”;
 } 
}
?>
        </select>
  </td>
  <td align=center width=”50%”>
  <select name=”showpro” onChange=”product_change()”>  
  <option value=”” selected>选拔成品</option>
<?php

$sqlp=”SELECT * FROM product where companyid=’$companyid'”;
$resultp = mysql_query($sqlp,$conn卡塔尔(قطر‎ or die(“数据库操作不当”卡塔尔国;
while ($userrowp=mysql_fetch_Array($resultp)){
 // 彰显该产物音信
 if ($showpro==$userrowp[productid]){
  $productid=$userrowp[productid];
  $name=$userrowp[name];
  $brand=$userrowp[brand];
  $type=$userrowp[type];
  $intro=$userrowp[introduction]; 
  echo “<option value=$userrowp[productid]
selected>$userrowp[productid]:$userrowp[name]</option>”;
 }
 else {
  echo “<option
value=$userrowp[productid]>$userrowp[productid]:$userrowp[name]</option>”;  
 } 
}
?>
  </select>
  </td></tr></table>
      </td>
    </tr>
    <tr>
      <td width=”28%” align=”center” > </td>
      <td width=”72%”> </td>
    </tr>
 <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>厂商ID:</td>
   <?
  // 显示原记录
  if ($show!=””){
   echo “<td width=’72%’>$companyid:$companyname</td>”;
   echo “<input type=hidden name=’old_id’
value=”.$companyid.”>”;
  }
  // 加多新记录
  else {
   echo “<td width=’72%’>请选用商家</td>”;
   // 设置产物音信变量为空   
   $name=””;
   $brand=””;
   $type=””;
   $intro=””;   
   $showpro=””;
  }
   ?>
     
    </tr>
 
 <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>产品ID:</td>
   <?
  // 展现原记录
  if ($showpro!=””){
   echo “<td width=’72%’>$productid</td>”;
   echo “<input type=hidden name=’old_pid’
value=”.$productid.”>”;
  }
  // 增加新记录
  else {
   echo “<td width=’72%’>请接纳成品</td>”;   
  }
   ?>
     
    </tr>
 
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>付加物名称:</td>
      <td width=”72%”>
  <?
  // 倘若接纳了成品,则突显产物消息
  if ($showpro!=””){
   echo $name;
  }
  // 若无选取产物,则不显得此外新闻
  else {
   echo ” “;
  }
  ?>
      </td>
    </tr>
   
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>付加货物牌:</td>
      <td width=”72%”>
   <?
  if ($showpro!=””){
   echo $brand;
  }
  else {
   echo ” “;
  }
  ?>
      </td>
    </tr>
 
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>产物类型:</td>
      <td width=”72%”>
   <?
  if ($showpro!=””){
   echo $type;
  }
  else {
   echo ” “;
  }
  ?>
      </td>
    </tr>
   
    <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>付加物介绍:</td>
      <td width=”72%”>
    <?
  if ($showpro!=””){
   echo $intro;
  }
  else {
   echo ” “;
  }
  ?>
      </td>
    </tr>
   
 <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>购买数码:</td>
      <td width=”72%”>
     <input type=”text” name=”amount” size=”30″ maxlength=”50″>
   </td>
    </tr>
   
    <tr>
      <td width=”28%” align=”center” bgcolor=”#F0F8FF”>单   
价:</td>
      <td width=”72%”>
  <input type=”text” name=”buyprice” size=”30″ maxlength=”50″
>元
      </td>
    </tr>
 <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>总花费:</td>  
   <td width=’72%’>自动测算</td>     
    </tr>
    <tr>
      <td width=”28%” align=”center” bgcolor=”#F0F8FF”>备   
注:</td>
      <td width=”72%”>
    <textarea name=”other” cols=”60″ rows=’5′></textarea> 
      </td>
    </tr>
   
    <tr align=”center”>
      <td colspan=”2″>        
  <?php
  // 选用了成品才方可购置
  if ($showpro!=””){
   echo “<input type=submit name=buy value=’购   买’>”;
  }  
  ?>
      </td>
    </tr>
  </table>
</form>
<?
}
// 要是是付出后甩卖
else {
 // 查看新闻是或不是填写完整
 if (($amount==””)||($buyprice==””)||($old_pid==””)||($old_id==””)){
  echo “<div align=center><font
color=red>未有采取付加物或信息未有填写完整!</font></div>”;
  exit();
 }
// 能够购置
// 取妥善前时间和前段时间
$now = date(“Y-m-d H:i:s”);
// 拿到登入ip.
$ip=getenv (REMOTE_ADDR);
$person=$_SESSION[‘user’];
$cost=$buyprice*$amount;
// 记录此次购买移动
$buysql=”insert into buylog(user, productid, amount, buyprice, cost, ip,
buytime, other) values(‘$person’, ‘$old_pid’, ‘$amount’, ‘$buyprice’,
‘$cost’, ‘$ip’, ‘$now’, ‘$other’)”;
mysql_query($buysql,$conn卡塔尔国 or die(“购买付加物失利: “.mysql_error());
// 登记已购买的产品入库
$sellprice=$buyprice*1.20;
// 检查是或不是原来就有该成品存货况且进价相像
$result=mysql_query(“select * from stock where productid=’$old_pid’
and buyprice=’$buyprice'”, $conn);
$row=mysql_fetch_array($result);
// 若无存货,登记存货
if (empty($row)){
 $sql=”insert into stock(productid, amount, buyprice, sellprice, cost,
introduction, buytime, other) values(‘$old_pid’, ‘$amount’,
‘$buyprice’, ‘$sellprice’, ‘$cost’, ‘$intro’, ‘$now’, ‘$other’)”;
 mysql_query($sql,$conn卡塔尔(قطر‎ or die(“购买产物失利: “.mysql_error());
}
// 若是原来就有存货,数量扩展
else {
 $amount+=$row[amount];
 $cost+=$row[cost];
 $sql=”update stock set amount=$amount, cost=$cost, buytime=$now where
productid=’$old_pid’ and buyprice=’$buyprice'”;
 mysql_query($sql, $conn卡塔尔(قطر‎ or die(“购买产物退步: “.mysql_error());
}

?>
<p align=”center”> </p>
<p align=”center”> </p>
<p align=”center”><font
color=”red”>购买成功!</font><br></p>
<p align=”center”><a href=”<?php echo $PHP_SELF
?>”>继续增加</a><br>
</p><?php } ?>

</body>
</html>

 

 

理之当然货好了,大家要贩卖商品了,就能出发售页面.
销售sell.php

<?
//初始化session
session_cache_expire(30);
session_start();

// 若无登入,退出
if(!isset($_SESSION[‘user’])) {
   echo “<p align=center>”;
   echo “<font color=#FF0000 size=5><strong><big>”;
   echo “您还不曾登入,请<a href=’login.php’>登陆</a>!”;
   echo “</big></strong></font></p>”;
   exit();
}
include (‘head.php’);
require (‘dbconnect.php’);
?>
<script language=”JavaScript”>

function product_change(){
// alert(document.form1.showpro.value);
 form1.submit();
}
</script>
<html>
<body>
<?php
// 假使是付出前
if ($sell==””) { ?>
<form name=”form1″ method=”post” action=”<?php echo $PHP_SELF
?>” >
  <table width=”60%” border=”0″ cellspacing=”1″ cellpadding=”3″
align=”center” bordercolor=”#8695AC”>
    <tr>
      <th colspan=”2″>销 售 登 记</th>
    </tr>
    <tr align=”center”>
      <td colspan=”2″> </td>
    </tr>
    <tr align=”center”>
      <td colspan=”2″>  
  <select name=”showpro” onChange=”product_change()”>  
  <option value=”” selected>接受存货产物</option>
<?php
$sqlp=”SELECT * FROM stock “;
$resultp = mysql_query($sqlp,$conn) or die(“数据库操作错误”卡塔尔国;
while ($userrowp=mysql_fetch_Array($resultp)){
 // 显示该产物新闻
  
  // 获得该成品的详细音信
  $ps教程ql=”select * from
product where productid=’$userrowp[productid]'”;
  $presult=mysql_query($psql,$conn);
  $prow=mysql_fetch_array($presult);  
  
 if ($showpro==$userrowp[productid]){ 
  $productid=$userrowp[productid];
  $amount=$userrowp[amount];
  $sellprice=$userrowp[sellprice];
  $buyprice=$userrowp[buyprice];
  $buytime=$userrowp[buytime];

  $name=$prow[name];
  $brand=$prow[brand];
  $type=$prow[type];
  $intro=$prow[introduction];
  // 拿到该成品的厂商名称
  $cresult=mysql_query(“select * from company where
id=’$prow[companyid]'”,$conn);
  $crow=mysql_fetch_array($cresult);
  $companyid=$crow[id];
  $companyname=$crow[name];
  echo “<option value=$userrowp[productid]
selected>$userrowp[productid]:$prow[name]</option>”;
 }
 else {
  echo “<option
value=$userrowp[productid]>$userrowp[productid]:$prow[name]</option>”;  
 } 
}
?>
  </select>  
      </td>
    </tr>
    <tr>
      <td width=”28%” align=”center” > </td>
      <td width=”72%”> </td>
    </tr>
 <tr>
      <td width=”28%” align=”center”
bgcolor=”#F0F8FF”>厂商ID:</td>
   <?
  // 选拔了存货
  if ($showpro!=””){
   echo “<td width=’72%’>$companyid:$companyname</td>”;   
  }
  // 没有接收存货
  else {
   echo “<td width=’72%’>请选取存货</td>”;
   // 设置付加物音信变量为空   
   $name=””;
   $brand=””;
   $type=””;
   $intro=””;   
   $showpro=””;
   $amount

发表评论

电子邮件地址不会被公开。 必填项已用*标注