Program | data | database
Db.func:
?
function GetRows ($Database, $Query) {
Mysql_connect ("ftp", "Root", "");
$db = mysql_select_db ($Database);
if (! $db) {
echo cannot link the database! ";
Exit
}
$rows = mysql_query ($Query);
if (! $rows) {
echo "SQL instruction error!";
Exit
}
return $rows;
}
function Connectdatabase ($Database) {
Mysql_connect ("ftp", "Root", "");
$db = mysql_select_db ($Database);
if (! $db) {
echo cannot link the database! ";
Exit
}
}
?>
cratetable.php:
?
function CreateTable () {
$link = mysql_connect ("ftp", "Root", "");
$db = mysql_select_db ("Pcadmin");
if (! $db) {
Echo failed to connect to the database! ";
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, 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:
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Input Form </title>
<style type= "Text/css" >
<!--
. INPUT {
border:1px solid #003C74;
}
. Font {
Font-family: "New song Body";
font-size:14px;
Color: #0000FF;
Font-weight:lighter;
}
. Table {
border:1px solid #000000;
}
. title {
Font-family: "New song Body";
font-size:14px;
Color: #FF0000;
}
-->
</style>
<body></CENTER><HR size= "1" noshade>
<form name= "Form1" method= "Post" action= "insert.php" >
<table width= "Align=center>"
<tr>
<th scope= "Row" ><div align= "left" class= "Font" > main machine name </div></th>
<td><input name= "name" type= "text" class= "input" ></td>
</tr>
<tr>
<th scope= "Row" ><div align= "left" class= "Font" > producer </div></th>
<td><input name= "Produce" type= "text" class= "input" ></td>
</tr>
<tr>
<th scope= "Row" ><div align= "left" class= "font" > Contact person </div></th>
<td><input name= "Lianluo" type= "text" class= "input" > </td>
</tr>
<tr>
<th scope= "Row" ><div align= "left" class= "font" > Contact person phone </div></th>
<td><input name= "Tel" type= "text" class= "input" ></td>
</tr>
<tr>
<th scope= "Row" ><div align= "left" class= "font" > Email box </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" > Application name </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 ' > config file </div></th>
<td><textarea name= "Directory" cols= "rows=" 5 "class=" INPUT "clums=" ></textarea></td>
</tr>
<tr>
<th scope= "Row" ><input name= "Send" type= "submit" class= "input" value= "submitted" ></th>
<td><input name= "Submit" type= "reset" class= "input" value= "rewrite" >
<a href= "show.php" > View records </a></td>
</tr>
</table>
</FORM><HR size= "1" noshade>
<p> </p>
</body>
insert.php:
<HTML>
<style type= "Text/css" >
<!--
. Font {
Font-family: "New song Body";
font-size:14px;
Font-weight:lighter;
Color: #FF0000;
}
-->
</style>
<body bgcolor= "#FFFFFF" >
<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>
show.php:
?
function Showonepage ($rows, $No) {
Mysql_data_seek ($rows, $No);
echo "<table border=1 align=center bordercolordark= ' #ffffff ' bordercolorlight= ' #000000 ' cellpadding= ' 3 ' cellspacing= ' 0 ' > ';
echo "<tr bgcolor=cyan>";
while ($field = Mysql_fetch_field ($rows)) {
echo ' <TD> '. $field->name. "</TD>";
}
echo "</TR>";
$nums = mysql_num_rows ($rows);
for ($I =1 $I <=10; $I + +) {
if ($row = Mysql_fetch_row ($rows)) {
& nbsp; for ($K =0 $K < count ($row); $K + +) {
& nbsp; echo "<td align=right>". $row [$K]. "</TD>";
}
echo "</TR>";
}
}
echo "</TABLE>";
}
<HTML>
<style type= "Text/css" >
<!--
. title {
Color: #FF0000;
Font-family: "New song Body";
font-size:14px;
}
. body {
Font-family: "New song Body";
font-size:12px;
Font-weight:lighter;
Color: #0000FF;
}
-->
</style>
<title> Server list </title><body bgcolor= "#FFFFFF" >
<HR size= "1" noshade color= "#0000ff" class= "HR" >
</H2>
?
Include (".. /db.func ");
$rows = GetRows ("Pcadmin", "SELECT * from Profile");
$num = mysql_num_rows ($rows);
$Pages = Intval (($num-1)/10) + 1;
if ($Page < 1) $Page = 1;
if ($Page > $Pages) $Page = $Pages;
Showonepage ($rows, ($Page-1) *10);
?>
<HR size= "1" noshade color= "#0000ff" class= "HR" >
<form action=<? echo $PHP _self;? > Method=get >
<div align=right>
?
if ($Page <> 1) {// When not the first page
echo "<a href= $PHP _self? Page=1> first page </a> ";
echo "<a href= $PHP _self? Page= ". ($Page-1). "> On a page </a>";
}
if ($Page <> $Pages) {// When not the last page
echo "<a href= $PHP _self? Page= ". ($Page + 1). "> Next page </a>";
echo "<a href= $PHP _self? page= $Pages > last page </a> ";
}
?>
<span class= "Body" > Jump </span>:
<input Type=text name=page size=3>
<span class= "Body" > Current page </span>:<font color=red><?echo $Page;? >/<?echo $Pages;? >
</DIV>
</FORM>
</BODY>
</HTML>
cxshow.php:
<title>get id</title>
<?php
if ($id) {
Edit Status, select a record
Include (".. /db.func ");
Mysql_connect ("ftp", "Root", "");
mysql_select_db ("Pcadmin");
$sql = "Update profile set Name= ' $Name ', produce= ' $Produce ', lianluo= ' $Lianluo ', tel= ' $Tel ', email= ' $Email ' where id=5";
mysql_query ($sql);
$rows = GetRows ("Pcadmin", "select * from profile where id= $id");
$myrow = Mysql_fetch_array ($rows);
$id = $myrow ["id"];
$Name = $myrow ["Name"];
$Produce = $myrow ["Produce"];
$Lianluo = $myrow ["Lianluo"];
$Tel = $myrow ["Tel"];
$Email = $myrow ["Email"];
echo "Your ID is ' $id '";
Exit
} else {
echo "failure!";
Exit
}
?>
printf.php:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Untitled Document </title>
<body>
<?php
$db =mysql_connect ("ftp", "Root", "");
mysql_select_db ("Pcadmin", $db);
if ($ID) {
echo "has ID case, ID is: $ID <br>";
if ($submit) {
echo "Executes the:<br> when submit";
$sql = "Update profile set Name= ' $Name ', produce= ' $Produce ', lianluo= ' $Lianluo ', tel= ' $Tel ', email= ' $Email ' where id= $ID" ;
$result = mysql_query ($sql);
echo "Thank you! Information updated! ";
} else {
echo "did not perform submit:<br>";
$sql = "SELECT * from profile where id= $ID";
$result = mysql_query ($sql);
$myrow = Mysql_fetch_array ($result);
?>
<form action =.? echo $PHP _self;? > method=post>
<input type=hidden name= "id" value= "<?php echo $myrow [" id "]?>" >
Name: <input type= "test" name= "name" value= " echo $myrow ["Name]?>" ><br>
Manufacturer: <input type= "test" name= "produce" value= " echo $myrow ["Produce"]?> "><br>
Contact: <input type= "test" name= "Lianluo" "value=" echo $myrow ["Lianluo"]?> "><br>
Tel: <input type= "Test" name= "tel" value= " echo $myrow ["Tel"]?> ><br>
E-mail: <input type= "test" name= "email" value= " echo $myrow ["Email"]?> "><br>
<input type= "Submit" name= "submit" value= "Input Info" >
</form>
?
}
} else {
echo "Case:<br> without ID";
$result = mysql_query ("SELECT * from Profile", $db);
if ($myrow = mysql_fetch_array ($result)) {
do {
printf ("<a href=\"%s?id=%s\ ">%s%s%s%s</a><br>\n", $PATH _info, $myrow ["ID"], $myrow ["Name"],$ myrow["Produce"], $myrow ["Lianluo"], $myrow ["Tel"], $myrow ["Email"]);
while ($myrow = Mysql_fetch_array ($result));
} else {
echo "Sorry, did not find the relevant records!" ";
Exit
}
}
?>
delete.php:
<title> Delete a record </title><?php
$db = mysql_connect ("ftp", "Root", "");
mysql_select_db ("Pcadmin", $db);
$sql = "Delete from profile where id= $ID";
$result =mysql_query ($sql);
echo "Delete one record!";
?>