Php Small Enterprise Inventory Management System Design and Implementation Code

Source: Internet
Author: User
Tags php and mysql

I have developed a small enterprise inventory management system using a combination of PHP and mysql. Php is also self-developed for the first time. I would like to share it with you here

Check_login Module

Copy codeThe Code is as follows: <! -- User Login test module -->
<? Php
Session_start ();
$ Workid = $ _ GET ['wid']; // GET the work ID
If ($ workid! = $ _ SESSION ['$ workid'] | $ workid = ''){
Echo "<script language = javascript> alert ('You have not logged on yet and cannot manage it! '); Location. href = 'login. php'; </script> ";
}
?>

Function. inc // mainly includes the database connection moduleCopy codeThe Code is 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;
}
?>

Repository management interface storage. phpCopy codeThe Code is as follows: <! -- Repository administrator management interface -->
2 <? Php
3 include "inc/check_login.php ";
4 include "inc/function. inc ";
5 $ id = mysql_link ("storage", "storage"); // create a storage connection
6
7 $ query = "select * from admin where admin_id = '$ workid'"; // locate the Repository
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">
<Html>
<Head>
<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 the font style */
Font-size: 12px;
Margin: 0px 240px;
Height: auto;
Width: 800px;
Border: 1px solid #006633;
Background-color: rgb (195,245,200 );

}
</Style>
</Head>
<Body>
<Div id = "header"> </div>
<Ul id = "nav">
<Li> <a href = "logout. php"> sales note </a> </li>
<? Php
Echo "<li> <a href = input. php? Wid = ". $ workid."> database entry </a> </li> ";
Echo "<li> <a href = output. php? Wid = ". $ workid."> outbound database </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 the Repository Information
$ Result = mysql_query ($ query, $ id );
If (mysql_num_rows ($ result) <1 ){
Echo "No repository". $ stoid;
} Else {
$ Info = mysql_fetch_array ($ result, MYSQL_ASSOC );
Echo "warehouse No :". $ stoid. "total capacity :". $ info ['Storage _ Cap']. "remaining capacity :". $ info ['Storage _ lcap']."
Repository address: ". $ info ['Storage _ add']." repository Phone: ". $ info ['Storage _ tele'];
If (! Mysql_select_db ("basicbase", $ id )){
Die ("Can \'t select_db:". mysql_error ());
}
// Create the warehouse view, warehouse receiving view, and warehouse picking view in basicbase
// Determine whether a view exists. If no view exists, create a view.
$ Query = "select * from". $ stoid. "_ inventory ";
If (! Mysql_query ($ query, $ id )){
// Create an inventory View
$ Query = "create view". $ stoid. "_ inventory
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
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
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> This warehouse is empty currently ";
} 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> there are a total of". $ totalnum. "goods in the warehouse. ";
Echo "page". $ pagesize. ", total". $ 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 "<tr> <td id = table_title> goods id </td> <td id = table_title> goods name </td> <td id = table_title> goods quantity </td> </tr> ";
Echo "<tr> <td> goods id </td> <td> goods name </td> <td> goods 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']. "</td> <td id = table_title> ". $ info ['name']. "</td> <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"> copyright: Freeze & zhaoL <br> Email: zhoujiebin15@qq.com </div>
</Body>
</Html>

There are too many codes, but I encountered a lot of problems during the first writing, but the program is still running anyway.

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.