金沙注册网站-新金沙官网 新金沙官网 金沙注册网站产品进销存管理系统开发实例教程,mysql一个名片库程序

金沙注册网站产品进销存管理系统开发实例教程,mysql一个名片库程序

用php+mysql一个名片库程序,有分类查找,分页功能。

首页文件 index.html

第一步:按下列代表先做个静态页面。
<form method=”post” action=”find1.php” name=”card” onSubmit=”return
card_Validator(this)”>
          <table width=”400″ border=”0″ cellspacing=”0″
cellpadding=”0″ class=”p10″>
            <tr>  
              <td colspan=”2″ height=”79″>  
                <table width=”280″ border=”0″ cellspacing=”0″
cellpadding=”0″ class=”p10″>
                  <tr>  
                    <td colspan=”3″ height=”37″>输入关键字:
<input type=”text” name=”keyword” class=”c3a”>
                    </td>
                  </tr>
                  <tr>  
                    <td>  
                      <input type=”radio” name=”inout” value=”N”
checked>
                      按姓名</td>
                    <td>  
                      <input type=”radio” name=”inout”
value=”C”>
                      按地区</td>
                    <td>  
                      <input type=”radio” name=”inout”
value=”A”>
                      按职位</td>
                  </tr>
                </table>
              </td>
            </tr>
            <tr>  
              <td colspan=”2″ height=”47″>  
                <input type=”submit” name=”query1″ value=”查找”>
                <input type=”reset” name=”Submit2″ value=”清除”>
              </td>
            </tr>
          </table>
        </form>
第二步:如下建库。
id  int(4)    否    auto_increment   
http  varchar(25)    否
name  varchar(50)    否       
email  varchar(50)    否       
gs  varchar(200)    否       
address  varchar(200)    否        
yb  varchar(20)    否       
zw  varchar(100)    否       
tel  varchar(20)    否       
fax  varchar(20)    否       
bp  varchar(20)    否       

<HTML>
<HEAD>
<TITLE> 产品进销存管理系统 </TITLE>
</HEAD>

第三步:查找执行程序
<?php

<BODY>

if (!isset($show)) $show=0;

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

{   

 

if($query1==”查找”)

 

{

头部.head.php

$db=mysql_connect(“localhost”,”用户名”,”密码”);
$dbname=mysql_select_db(“库文件名”,$db);
mysql_query(‘select * from 表文件名’,$db);
$limit=2; //一页显示几条内容。

 

//global $query,$queryyy,$quer;
switch($inout)

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

{

 

   case “N”:  
  //按姓名查找
$query=”select * from card where name like ‘%$keyword%'”;  

 

  
$queryyy = “select * from card where name like ‘%$keyword%’ order by id
desc limit $show, $limit”;    

数据库教程连接文件dbconnect.php

   break;

 

   case “C”:
   //按地区查找
$query=”select * from card where address like ‘%$keyword%’ order by id
desc”;  

<?php
$conn=mysql教程_connect(“localhost”,”phpdb”,”phpdb”)
        or die(“不能连接数据库服务器: “.mysql_error());
mysql_select_db(“product”,$conn) or die (“不能选择数据库:
“.mysql_error());

    $queryyy = “select * from card where address like ‘%$keyword%’
order by id desc limit $show, $limit”;         
   break;

?>
数据库结构:
product.sql

   case “A”:  
  // 按职务查找
   $query=”select * from card where zw like ‘%$keyword%’ order by id
desc”;  

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

  $queryyy = “select * from card where zw like ‘%$keyword%’ order by id
desc limit $show, $limit”;    
   break;

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

   }
$result1=mysql_query($query);  
$total=mysql_num_rows($result1); //总的符合条件的记录数  

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

$quer=mysql_query($queryyy,$db);
$pages=ceil($total/$limit);
  }
  }

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

  <p><font color=”#FF0000″ face=”宋体”
size=”3″><strong><span style=”font-size: 12pt”><font
size=”4″
color=”#000000″>你查找的关键字是:</font></span></strong></font>:<font
color=red><? echo $keyword;?></font></p>

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

echo “<table width=’400′ border=’0′ cellspacing=’0′ cellpadding=’0′
align=’center’>
  <tr>
    <td width=’314′>
      <div align=’center’>查找名片如下: 共有[<font
color=red>”;
      echo $total;
       echo “</font>]张名片</div>
    </td>
    <td width=’86’>
      <div align=’right’>共分[<font color=red>”;
      echo $pages;

 

     echo “</font>]页 </div>
    </td>
  </tr>
</table>”;

 

while ($row = mysql_fetch_array($quer))
{

 

echo “<table width=’440′ border=’1′ cellspacing=’0′ cellpadding=’0′
height=’175′ align=’center’ bordercolordark=’#eeeeee’
bordercolorlight=’#666666′>    

下面我们从用户注册开始。打开index.html文件,点击注册,

<tr>
    <td>
      <table width=’380′ border=’0′ cellspacing=’0′ cellpadding=’0′
align=’center’ bgcolor=’#eeeeee’>
        <tr>  
          <td colspan=’2′ height=’53’>  
            <div align=’center’ class=’pp13′><font
color=’#000000′>$row[gs]</font></div>
          </td>
        </tr>
        <tr>  
          <td height=’35’ colspan=’2′ align=center>  
     <b class=’pp13′>$row[name] <span
class=’pp9′>$row[zw] <br>
              </span></b>
              <hr color=’#FFCC00′ noshade size=’1′>

注册reg.php

          </td>
        </tr>
        <tr>  
          <td colspan=’2′>  
            <ul>
              <li><span
class=’pp10′>电话:$row[tel]</span></li>
              <li><span
class=’pp10′>传真:$row[fax]</span></li>
              <li><span
class=’pp10′>网址:$row[http]</span></li>
              <li><span
class=’pp10′>电子信箱:$row[eamil]</span></li>
              <li><span
class=’pp10′>地址:$row[address]</span></li>
              <li><span
class=’pp10′>邮编:$row[yb]</span></li>
              <li><span
class=’pp10′>BP:$row[bp]</span></li>
            </ul>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  </table><br>”;

<?
include(“head.php”);
?>
<script
language=”javascript教程”>
    function checkreg()
    {    
  if (form1.name.value==””)
  {
   // 如果真实姓名为空,则显示警告信息
         alert(“真实姓名不能为空!”);
   form1.name.focus();
   return false;
     }
  if (form1.password.value==”” )
  {
   // 如果密码为空,则显示警告信息
         alert(“密码不能为空!”);
   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(“两次密码不一样,请确认!”);
   form1.password.focus();
   return false;
  }  
  return true;

        
}

    } 
</script>

$vor = $show + $limit;
$back = $show – $limit;
print “<center>”;

<html>
<body>

print “<table width=”455″ border=”0″ bordercolor=”#FFCC33″
cellspacing=”0″ align=”center” >”;
print “<tr  height=”20″ bgcolor=”#FFD6AC”><td width=”350″
>”;
for ($i=1;$i<=$pages;$i++)
{
    $new_offset=$limit*($i-1);
    $parameter=”query1=$query1&keyword=$keyword&inout=$inout”;

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

     
    print “<a href=”$PHP_SELF?show=$i&$parameter”><b>
$i</b></a>$nbsp”;
}
print “</td><td width=”45″ >”;
//显示上一页
if ($show – $limit >= 0)
{
print ” <a
href=”$PHP_SELF?show=$back&$parameter”>上一页</a>”;
}
print “</td><td width=”45″>”;
//显示下一页
if (($show + $limit) < $total)
{
print “<a href=”$PHP_SELF?show=$vor&$parameter”>下一页</a>
“;
}
print “</td><td width=”60″>”;
//显示全部留言
//print “<a
href=”$PHP_SELF?show=all.&$parameter”>全部名片</a> “;
print “</td></tr></table>”;
print “</center>”;
?>
若有问题请mailto:lyjrich@sina.com,这个程序有个问题如果要显示全部名片的话,我这个程序还没有实现此功能,如果你知道在这个程序里怎样显示全部名片的话希望能发mail给我。  

 

【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】    

 

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

?>

 

相关文章

发表评论

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

网站地图xml地图