...
双专业毕业论文做了一个小型企业库存管理系统,使用PHP&mysql组合进行开发。头一次开发稍微大一点的东西,php也是自学的。这里想跟大家一起分享一下
check_login 模块
复制代码 代码如下:
session_start();
$workid=$_GET['wid'];//获取工作号
if($workid!=$_SESSION['$workid']||$workid==''){
echo "";
}
?>
function.inc//主要包括数据库连接模块
复制代码 代码如下:
function mysql_link($user="admin",$password="admin",$database="systembase"){
$id=mysql_connect("localhost",$user,$password);
if(!$id){
die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db($database,$id)){
die ("Can\'t select_db : " . mysql_error());
}
//改变客户端字符集编码为gb2312
mysql_query("SET NAMES gb2312");
return $id;
}
?>
仓库管理界面storage.php
复制代码 代码如下:
2 3 include "inc/check_login.php";
4 include "inc/function.inc";
5 $id=mysql_link("storage","storage");//建立storage连接
6
7 $query="select * from admin where admin_id='$workid'";//定位仓库
8 $result=mysql_query($query,$id);
9 $info=mysql_fetch_array($result,MYSQL_ASSOC);
$stoid=$info['storage_id'];
?>
仓库管理
$query="select * from storage where storage_id='$stoid'";//定位仓库信息
$result=mysql_query($query,$id);
if(mysql_num_rows($result)echo "没有仓库".$stoid;
}else{
$info=mysql_fetch_array($result,MYSQL_ASSOC);
echo "仓库号:".$stoid." 总容量:".$info['storage_cap']." 剩余容量:".$info['storage_lcap']."
仓库地址:".$info['storage_add']." 仓库电话:".$info['storage_tele'];
if (!mysql_select_db("basicbase",$id)){
die ("Can\'t select_db : " . mysql_error());
}
//在basicbase中建立对应仓库货物视图,入库视图以及出库视图
//判断是否存在相关视图,没有的话就新建视图
$query="select * from ".$stoid."_inventory";
if(!mysql_query($query,$id)){
//创建inventory视图
$query="create view ".$stoid."_inventory as
select inventory.goods_id,name,number from inventory,systembase.goods where storage_id=".$stoid." and inventory.goods_id=systembase.goods.goods_id";
if(!mysql_query($query,$id)){
die ("Can\'t create_view_inventory : " . mysql_error());
}
//创建input视图
$query="create view ".$stoid."_input as
select input_id,goods_id,number,time from input where admin_id=".$workid;
if(!mysql_query($query,$id)){
die ("Can\'t create_view_input : " . mysql_error());
}
//创建output视图
$query="create view ".$stoid."_output as
select output_id,goods_id,number,time from output where admin_id=".$workid;
if(!mysql_query($query,$id)){
die ("Can\'t create_view_output : " . mysql_error());
}
}
$query="select * from ".$stoid."_inventory";
$result=mysql_query($query,$id);
if(mysql_num_rows($result)echo "
该仓库目前是空的";
}else{
$totalnum=mysql_num_rows($result);
$pagesize=7;
$page=$_GET["page"];
if(""==$page){
$page=1;
}
$begin=($page-1)*$pagesize;
$totalpage=ceil($totalnum/$pagesize);
echo "仓库*有".$totalnum."种货物。";
echo "每页".$pagesize."种,共".$totalpage."页。
";
for($j=1;$jecho "[".$j."] ";
}
echo "
";
$query="select *from ".$stoid."_inventory order by goods_id limit $begin,$pagesize";
$result=mysql_query($query,$id);
$datanum=mysql_num_rows($result);
//echo "
货物id |
货物名称 |
货物数量 |
";
echo "
货物id |
货物名称 |
货物数量 |
";
for($i=1;$i$info=mysql_fetch_array($result,MYSQL_ASSOC);
//echo "
".$info['goods_id']." |
".$info['name']." |
".$info['number']." |
";
echo "
".$info['goods_id']." |
".$info['name']." |
".$info['number']." |
";
}
}
}
mysql_close($id);
?>
代码太多不一一贴了,第一次写碰到很多问题,但不管怎么说程序还是运行起来了