首页 > php代码 > 一个对数据库进行操作的程序

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

db.func:


<?php

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:


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


教程网址:http://www.phprm.com/code/fd59b34b7ae2ecf6f76ef91b579d1c6d.html

欢迎收藏∩_∩但请保留本文链接。

标签:none

发表留言