Design and implementation of inventory management system for small PHP enterprises Code _php Instance

Source: Internet
Author: User
Tags character set

Bi-Professional graduation thesis has done a small enterprise inventory management system, using PHP&MYSQL combination for development. The first time to develop something a little bigger, PHP is also self-study. Here to share with you

Check_login Module

Copy Code code as follows:

<!--user Login Inspection module-->
<?php
Session_Start ();
$workid =$_get[' wid '];//get work number
if ($workid!=$_session[' $workid ']| | $workid = = ") {
echo "<script language=javascript>alert (' You haven't landed, can't manage! '); location.href= ' login.php ';</script> ';
}
?>

function.inc//mainly includes database connection module
Copy Code code as follows:

<?php
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 ());
}
Change the client character set encoding to gb2312
mysql_query ("SET NAMES gb2312");
return $id;
}
?>

Warehouse Management Interface storage.php
Copy Code code as follows:

<!--warehouse Administrator management interface-->
2 <?php
3 include "inc/check_login.php";
4 include "Inc/function.inc";
5 $id =mysql_link ("Storage", "storage");/Establish storage connection
6
7 $query = "SELECT * from admin where admin_id= ' $workid '";//Locate Warehouse
8 $result =mysql_query ($query, $id);
9 $info =mysql_fetch_array ($result, MYSQL_ASSOC);
$stoid = $info [' storage_id '];
?>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "http://www.w3c.org/TR/1999/REC-html401-19991224/ Loose.dtd ">
<link href= "Images/style.css" Type=text/css rel=stylesheet>
<meta http-equiv=content-type content= "text/html; charset=gb2312 ">
<title> Warehouse Management </title>
<style type= "Text/css" >
body{
Font-family:arial,helvetica,sans-serif; /* Set Font style * *
font-size:12px;
margin:0px 240px;
Height:auto;
width:800px;
border:1px solid #006633;
Background-color:rgb (195,245,200);

}
</style>
<body>
<div id= "Header" ></div>
<ul id= "NAV" >
<li><a href= "logout.php" > Logoff </a></li>
<?php
echo "<li><a href=input.php?wid=". $workid. " > Warehousing </a></li> ";
echo "<li><a href=output.php?wid=". $workid. " > Out of the Library </a></li> ";
?>
</ul>
<div id= "Content" align=center>
<div id= "Man_zone" align=center>
<table width= "99%" border= "1" align= "Center" cellpadding= "3" cellspacing= "1" >
<?php
$query = "SELECT * from storage where storage_id= ' $stoid '";//Locate warehouse Information
$result =mysql_query ($query, $id);
if (mysql_num_rows ($result) <1) {
echo "No warehouse". $stoid;
}else{
$info =mysql_fetch_array ($result, MYSQL_ASSOC);
echo "Warehouse number:". $stoid. "Total Capacity:". $info [' Storage_cap ']. "Remaining capacity:" $info [' Storage_lcap ']. "
Warehouse address: ". $info [' Storage_add ']." Warehouse Tel: ". $info [' Storage_tele '];
if (!mysql_select_db ("Basicbase", $id)) {
Die ("can\ ' t select_db:".) Mysql_error ());
}
Set up warehouse cargo view, warehousing view, and out of library view in Basicbase
To determine whether there is a related view or not, create a new view
$query = "SELECT * from". $stoid. " _inventory ";
if (!mysql_query ($query, $id)) {
Create Inventory View
$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 ());
}
Create an input view
$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 ());
}
Create an output view
$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) <1) {
echo "<br> The warehouse is currently empty";
}else{
$totalnum =mysql_num_rows ($result);
$pagesize = 7;
$page =$_get["page"];
if ("" = $page) {
$page = 1;
}
$begin = ($page-1) * $pagesize;
$totalpage =ceil ($totalnum/$pagesize);

echo "<tr> warehouse in common". $totalnum. " kinds of goods. ";
echo "Every page". $pagesize. " Species, altogether ". $totalpage." Page. </tr> ";
for ($j =1; $j <= $totalpage; $j + +) {
echo "<a href=storage.php?wid=". $workid. " &page= ". $j."  >[". $j."] </a> ";
}
echo "<br>";
$query = "Select *from". $stoid. " _inventory ORDER BY goods_id limit $begin, $pagesize ";
$result =mysql_query ($query, $id);
$datanum =mysql_num_rows ($result);
echo "&LT;TR&GT;&LT;TD id=table_title > Goods id</td><td id=table_title > cargo name </td><td id=table_ Title > Quantity of Goods </td></tr> ";
echo "&LT;TR&GT;&LT;TD > Cargo id</td><td > Cargo name </td><td > Cargo quantity </td></tr>";
for ($i =1; $i <= $datanum; $i + +) {
$info =mysql_fetch_array ($result, MYSQL_ASSOC);
echo "<tr><td id=table_title >". $info [' goods_id ']. " &LT;/TD&GT;&LT;TD id=table_title > ". $info [' name ']." &LT;/TD&GT;&LT;TD id=table_title > ". $info [' number ']." </td></tr> ";
echo "<tr><td >". $info [' goods_id ']. " </td><td > ". $info [' name ']." </td><td > ". $info [' number ']." </td></tr> ";
}

}
}
Mysql_close ($id);
?>
</table>
</div>
</div>
<div id= "Footer" > All rights reserved: Freeze&zhaol <br>E-mail:zhoujiebin15@qq.com</div>
</body>

The code is too much to paste, the first time to write a lot of problems, but anyway, the program is still running

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.