modify.php:
$link = mysql_connect("localhost:3306", "root", "lili0921")
or die("Could not connect : " . mysql_error());
mysql_select_db("ykjd",$link) or die("Could not select database");
echo "数据库管理系统
";
parse_str($_SERVER['QUERY_STRING']);
$query = "SELECT * FROM products WHERE id = '$id'";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$Rnum = mysql_num_fields($result);
?>
mysql_free_result($result);
mysql_close($link);
?>
add.php:
check.php
delete.php
$link = mysql_connect("localhost:3306", "root", "lili0921")
or die("Could not connect : " . mysql_error());
mysql_select_db("ykjd",$link) or die("Could not select database");
parse_str($_SERVER['QUERY_STRING']);
$query = "delete from products where id = '$id'";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
if($result){
echo "删除成功,正在转回...";
?>
}
else{
echo "删除失败,正在返回...";
}
mysql_close($link);
?>
find.php
$link = mysql_connect("localhost:3306", "root", "lili0921")
or die("Could not connect : " . mysql_error());
echo "数据库管理系统
";
mysql_select_db("ykjd",$link) or die("Could not select database");
$query = "SELECT * FROM products WHERE serial='$_POST[findserial]'";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$Rnum = mysql_num_fields($result);
?>
echo "";
for($i = 0;$i < $Rnum;$i++){
$str = mysql_field_name($result,$i);
?> |
}
echo "
";
while($row = mysql_fetch_row($result)){
$j++;
echo "";
for($i = 0;$i < $Rnum; $i++){
echo "$row[$i] | ";
}
}
echo "
";
echo "返回首页"
?>
mysql_free_result($result);
mysql_close($link);
?>
getpasswd.php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
?>
$link = mysql_connect("localhost:3306", "root", "lili0921")
or die("Could not connect : " . mysql_error());
echo "Connected successfully";
?>
mysql_select_db("ykjd",$link) or die("Could not select database");
echo "dsaf";
$query = "SELECT * FROM user WHERE username = '$_POST[username]'";
print "\n";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
echo "kksf";
?>
echo "
";
echo "asdf";
$row = mysql_fetch_row($result);
echo "$row[1]";
echo "$_POST[password]";
if($row[1] == $_POST[password]){
echo "h1";
mysql_free_result($result);
$query = "SELECT * FROM products order by id asc";
$result = mysql_query($query) or die("Query failed :" . mysql_error());
$Rnum = mysql_num_fields($result);
?>
echo "";
for($i = 0;$i < $Rnum;$i++){
$str = mysql_field_name($result,$i);
?> |
}
echo "
";
$j = 1;
while(($row = mysql_fetch_row($result)) && ($j <= 10)){
$j++;
echo "";
for($i = 0;$i < $Rnum; $i++){
echo "$row[$i] | ";
}
echo "删除 | ";
echo "修改 | ";
}
echo "
";
?>
echo "添加   ";
echo "上一页   ";
echo "下一页";
mysql_free_result($result);
mysql_close($link);
}
?>
realadd.php
$link = mysql_connect("localhost:3306", "root", "lili0921")or die("Could not connect : " . mysql_error());
mysql_select_db("ykjd",$link) or die("Could not select database");
//$posttime = date('Y-m-d G:I:s',$_POST[posttime]);
//$userregistertime = date('Y-m-d H:I:s',$_POST[userregistertime]);
if($_POST[id]){
$query = "select id from products where id='$_POST[id]'";
$result = mysql_query($query);
if($result){
mysql_free_result($result);
$query = "delete from products where id='$_POST[id]'";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$query = "insert into products values('$_POST[id]','$_POST[serial]','$_POST[posttime]','$_POST[postbatch]','$_POST[userfingerno]','$_POST[userregistertime]','$_POST[userhistory]','$_POST[username]','$_POST[usercom]','$_POST[usertel]')";
}
else {
mysql_free_result($result);
$query = "insert into products values('$_POST[id]','$_POST[serial]','$_POST[posttime]','$_POST[postbatch]','$_POST[userfingerno]','$_POST[userregistertime]','$_POST[userhistory]','$_POST[username]','$_POST[usercom]','$_POST[usertel]')";
}
}
else{
$query = "select id from products";
$result = mysql_query($query) or die("Query failed : " .mysql_error());
for($j = 1;$row = mysql_fetch_row($result);$j++){
if($row[0] != $j) break;
}
$query = "insert into products values('$j','$_POST[serial]','$_POST[posttime]','$_POST[postbatch]','$_POST[userfingerno]','$_POST[userregistertime]','$_POST[userhistory]','$_POST[username]','$_POST[usercom]','$_POST[usertel]')";
}
$result = mysql_query($query);
if($result){
echo "记录添加成功,正在返回.....";
?>
"; ?>
}
else
{
echo "填写有错误,请重新填写...";
?>
}
?>
mysql_close($link);
?>
view.php
?>
$link = mysql_connect("localhost:3306", "root", "lili0921")
or die("Could not connect : " . mysql_error());
echo "数据库管理系统
";
?>
mysql_select_db("ykjd",$link) or die("Could not select database");
?>
if($opt){
switch($opt){
case 1:
$id = $id - 10;
$query = "SELECT * FROM products where id >'$id' order by id asc";
break;
case 2:
$query = "select * from products where id > '$id' order by id asc";
break;
}
} else {
$query = "select * from products order by id asc";
}
$result = mysql_query($query) or die("Query failed :" . mysql_error());
$Rnum = mysql_num_fields($result);
?>
echo "";
for($i = 0;$i < $Rnum;$i++){
$str = mysql_field_name($result,$i);
?> |
}
echo "
";
$j = 1;
while(($row = mysql_fetch_row($result)) && ($j <= 10) ){
$j++;
echo "";
for($i = 0;$i < $Rnum; $i++){
echo "$row[$i] | ";
}
echo "删除 | ";
echo "修改 | ";
}
echo "
";
?>
$opt1 = 1;
$opt2 = 2;
echo "添加   ";
?>
&opt=1>上一页   
&opt=2>下一页
mysql_free_result($result);
mysql_close($link);
?>
阅读(336) | 评论(0) | 转发(0) |