Double Professional graduation thesis made a small enterprise inventory management system, using PHP&MYSQL combination for development. The first time to develop something a little bigger, PHP is self-taught. I'd like to share it with you.
Check_login Module
Copy CodeThe code is as follows:
Session_Start ();
$workid =$_get[' wid '];//get work number
if ($workid!=$_session[' $workid ']| | $workid = = ") {
echo "";
}
?>
function.inc//mainly includes database connection module
Copy CodeThe code is as follows:
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 ());
}
Changing the client character set encoding to gb2312
mysql_query ("SET NAMES gb2312");
return $id;
}
?>
Warehouse Management Interface storage.php
Copy CodeThe code is as follows:
2 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 '];
?>
<title>Warehouse Management</title>
- Log off
echo "
- Finished
";
echo "
- Out of the library
";
?>
$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 Phone: ". $info [' Storage_tele '];if (!mysql_select_db ("Basicbase", $id)) {Die ("can\ ' t select_db:". Mysql_error ());}Build a warehouse cargo view, inbound view, and out-of-Library view in BasicbaseDetermine if there is a related view, and if not, create a new view$query = "SELECT * from". $stoid. " _inventory ";if (!mysql_query ($query, $id)) {Create a Inventory view$query = "CREATE View". $stoid. " _inventory asSelect 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 input View$query = "CREATE View". $stoid. " _input asSelect 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 asSelect 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 "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 "
There are ". $totalnum in the warehouse." of goods. "; echo "per page". $pagesize. " Species, total ". $totalpage." Page.
"; for ($j =1; $j <= $totalpage; $j + +) {echo "[". $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 "
Cargo ID |
Name of goods |
Quantity of goods |
"; echo "
Cargo ID |
Name of goods |
Quantity of goods |
"; for ($i =1; $i <= $datanum; $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);?>
All rights reserved: Freeze&zhaol
E-mail:zhoujiebin15@qq.com
Code too many do not post, first write encountered a lot of problems, but anyway, the program is still running up