Home >Backend Development >PHP Tutorial >A program that operates on the database_PHP tutorial

A program that operates on the database_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:19:47931browse

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:




輸入表單

輸入表單




 
   
   
 
 
   
   
 
 
   
   
 
 
   
   
 
 
   
   
 
 
   
   
 
 
   
   
 
 
   
   
 
 
   
   
 
主機名稱
生產廠商
聯絡人
     
聯絡人電話
聯絡人郵箱

IP Address


     
應用名稱
配置文件

      查看记录



 




insert.php:




成功輸入一筆資料去看看 


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

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

show.php:

function ShowOnePage( $rows, $No ) {
  mysql_data_seek( $rows, $No );
 

  echo "

";
  echo "";
  while ( $field = mysql_fetch_field($rows) ) {
     echo "";
  }
  echo "";
  $nums = mysql_num_rows($rows);
  for ( $I=1; $I <=10; $I++ ) {
     if ( $row = mysql_fetch_row($rows) ) {
          for ( $K=0 ; $K < count($row); $K++ ) {
           echo "";
        }
        echo "";
     }
  }
  echo "
" . $field->name . "
" . $row[$K] . "
";
}
?>



伺服器清单

伺服器清單
 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/532634.htmlTechArticledb.func: ? function GetRows( $Database, $Query ) { mysql_connect ("ftp", "root", ""); $db = mysql_select_db( $Database ); if ( ! $db ) { echo "无法连结数据库!"; exit; } $r...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn