快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

一个对数据库进行操作的程序

db.func:

<?
function GetRows( $Database, $Query ) {
   mysql_connect ("ftp", "root", "");
   $db = mysql_select_db( $Database );
   if ( ! $db ) {
      echo "无法连结数据库!";
      exit;
   }

   $rows = mysql_query( $Query );
   if ( ! $rows ) {
      echo "SQL指令错误!";
      exit;
   }
   return $rows;
}

function ConnectDatabase( $Database ) {
   mysql_connect ("ftp", "root", "");
   $db = mysql_select_db( $Database );
   if ( ! $db ) {
      echo "无法连结数据库!";
      exit;
   }
}
?>

cratetable.php:

<?
function CreateTable() {
   $link = mysql_connect ("ftp", "root", "");
   $db = mysql_select_db("pcadmin");
   if ( ! $db ) {
      echo "连接到数据库失败!";
      exit;
   }
   $rows = mysql_query("select * from Profile");
   if ( ! $rows ) {
      $sql = "Create Table Profile (ID integer auto_increment primary key,Name char(255),Produce char(255),Lianluo char(255),Tel integer(15),Email char(255))";
      mysql_query($sql);
   }
  
   $rows = mysql_query("select * from Aplication");
   if ( ! $rows ) {
      $sql = "Create Table Aplication(Name char(255) primary key,IP char(255),Ap char(255),Directory char(255))";
      mysql_query($sql);
   }
   mysql_close ($link);
}
CreateTable();
?>

input.htm:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>??入表?桅lt;/title>
<style type="text/css">
<!--
.INPUT {
 border: 1px solid #003C74;
}
.font {
 font-family: "新宋体";
 font-size: 14px;
 color: #0000FF;
 font-weight: lighter;
}
.table {
 border: 1px solid #000000;
}
.title {
 font-family: "新宋体";
 font-size: 14px;
 color: #FF0000;
}
-->
</style>
</head>

<body><h3><center class="title">??入表?渭BR></center><hr size="1" noshade>
</h3>

<form name="form1" method="post" action="insert.php">
<table width="400"align=center>
 <tr>
    <th scope="row"><div align="left" class="font">主?C名费</div></th>
    <td><input name="Name" type="text" class="input"></td>
  </tr>
  <tr>
    <th scope="row"><div align="left" class="font">生?a?S商</div></th>
    <td><input name="Produce" type="text" class="INPUT"></td>
  </tr>
  <tr>
    <th scope="row"><div align="left" class="font">??疥人</div></th>
    <td><input name="Lianluo" type="text" class="INPUT">      </td>
  </tr>
  <tr>
    <th scope="row"><div align="left" class="font">??疥人????</div></th>
    <td><input name="Tel" type="text" class="INPUT"></td>
  </tr>
  <tr>
    <th scope="row"><div align="left" class="font">??疥人噍箱</div></th>
    <td><input name="Email" type="text" class="INPUT"></td>
  </tr>
  <tr>
    <th scope="row"><p align="left" class="font">IP Address</p>
      </th>
    <td><input name="IP" type="text" class="INPUT"></td>
  </tr>
  <tr>
    <th scope="row"><div align="left" class="font">??用名费</div></th>
    <td><input name="Ap" type="text" class="INPUT"></td>
  </tr>
  <tr>
    <th align="left" valign="top" scope="row"><div align="left" class="font">配置文件</div></th>
    <td><textarea name="Directory" cols="40" rows="5" class="INPUT" clums="15"></textarea></td>
  </tr>
  <tr>
    <th scope="row"><input name="Send" type="submit" class="INPUT" value="提交"></th>
    <td><input name="Submit" type="reset" class="INPUT" value="重??">
      <a href="show.php">查看记录</a></td>
  </tr>
</table>

</form><hr size="1" noshade>
<p>&nbsp;</p>
</body>
</html>

insert.php:

<HTML>
<style type="text/css">
<!--
.font {
 font-family: "新宋体";
 font-size: 14px;
 font-weight: lighter;
 color: #FF0000;
}
-->
</style>
<BODY bgcolor="#FFFFFF">
<H3><a href="show.php" class="font">成功??入一剐儋料去看看</a> 
<HR></H3>
<?
include("../db.func");

if ( !empty($Send) ) {
   ConnectDatabase( "pcadmin" );
   $sql = "insert into Profile(Name,Produce,Lianluo,Tel,Email) values(\\'$Name\\',\\'$Produce\\',\\'$Lianluo\\',\\'$Tel\\',\\'$Email\\')";
  
   mysql_query( $sql );
    }
?>
</BODY>
</HTML>

本新闻共2页,当前在第1页  1  2  

本新闻共2页,当前在第1页  1  2  


返回类别: 教程
上一教程: 十天学会php之第五天
下一教程: 十天学会php之第九天

您可以阅读与"一个对数据库进行操作的程序"相关的教程:
· PHP中对数据库操作的封装
· 在线短消息收发的程序,不用数据库
· 一个连接两个不同MYSQL数据库的PHP程序
· 一个用mysql_odbc和php写的serach数据库程序
· 一个利用PHP语言读取数据库数据的例子
    微笑服务 优质保证 索取样品