dedecms织梦内容管理系统    
首页 | java | C/C++ | PHP | 操作系统 | ajax | 脚本编程 | 安全技术 | 本站下载页 | flex | CRM | 专题 | QQ群 | 测试中心 | 会员中心 | 积分规则
  当前位置:主页>PHP>php技术资料>文章内容
一个对数据库进行操作的程序
来源:未知     作者:    
 

db.func:

<?
function GetRows( $Database, $Query ) {
   _connect ("ftp", "root", "");
   $db = _select_db( $Database );
   if ( ! $db ) {
      echo "无法连结!";
      exit;
   }

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

function ConnectDatabase( $Database ) {
   _connect ("ftp", "root", "");
   $db = _select_db( $Database );
   if ( ! $db ) {
      echo "无法连结!";
      exit;
   }
}
?>

cratetable.:

<?
function CreateTable() {
   $link = _connect ("ftp", "root", "");
   $db = _select_db("pcadmin");
   if ( ! $db ) {
      echo "连接到失败!";
      exit;
   }
   $rows = _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))";
      _query($sql);
   }
  
   $rows = _query("select * from Aplication");
   if ( ! $rows ) {
      $sql = "Create Table Aplication(Name char(255) primary key,IP char(255),Ap char(255),Directory char(255))";
      _query($sql);
   }
   _close ($link);
}
CreateTable();
?>

input.htm:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>輸入表單</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">輸入表單
</center><hr size="1" noshade>
</h3>

<form name="form1" method="post" action="insert.">
<table width="400"align=center>
 <tr>
    <th scope="row"><div align="left" class="font">主機名稱</div></th>
    <td><input name="Name" type="text" class="input"></td>
  </tr>
  <tr>
    <th scope="row"><div align="left" class="font">生產廠商</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.">查看记录</a></td>
  </tr>
</table>

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

insert.:

<HTML>
<style type="text/css">
<!--
.font {
 font-family: "新宋体";
 font-size: 14px;
 font-weight: lighter;
 color: #FF0000;
}
-->
</style>
<BODY bgcolor="#FFFFFF">
<H3><a href="show." 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')";
  
   _query( $sql );
    }
?>
</BODY>
</HTML>

[1]  

 

 

上一篇:身份证方面的函数   下一篇:php+mysql扎实个人基本功
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论
  热点文章
·通过对PHP服务器端特性的配置加
·php与mysql三日通
·AJAX技术在PHP开发中的简单应用
·大家所使用的PHP开发环境
·PHP缓存的实现
·针对PHP新手总结的PHP基础知识
·一个简单实现多条件查询的例子
·PHP串行化变量和序列化对象
·PHP表单
·推荐阅读:php技术生成静态页面
·php实用函数
·php生成随机数
  相关文章
·身份证方面的函数
·php+mysql扎实个人基本功
·几个php技巧
·判断字符串emailAddr是否为合法
·用PHP写FTP文件上传
·PHP控制语句
·Win XP下全新安装Apache2,PHP5
·PHP的十个高级技巧
·用PHP写的MD5加密函数
·在PHP中以root身份运行外部命令
·关于session的问题集锦解决方案
·PHP编程常用技巧四则
  相关信息
copy right @ 百家拳软件项目研究室 2007 辽ICP备07011763