PHP 制作通讯录(三)
上一篇我们讲到链接到 Edit.php?id= 来修改数据,后来我想了一下,其实也可以直接利用 Input.php 来修改数据,这样更容易管理,节省了不必要的空间
Input.php可以这样链接:Input.php?id=[Num]&action=[Num]
id即记录ID,默认为-1
action为动作,默认为0 , 为0时代表添加新的记录,为1时则修改记录
Input.php中插入PHP代码:
<?php
//先设定默认值
$id = -1; //-1代表是添加数据
$action = 0; //0代表添加数据,1:修改数据
$formAction = "Post.php"; //表单的action
if($_GET['id']!=null)
$id = $_GET['id'];
if($_GET['action']!=null)
$action = $_GET['action'];
if($id!=-1 && $action!=0)
{
$formAction = "Post.php?id=$id&action=$action";
$sql = "SELECT * from `AddrList` WHERE Id=$id";
require('conn.php');
$row = MySQL_fetch_row($result);
$name = $row[1];
$sex = $row[2];
$birthday = $row[3];
$qq = $row[4];
$mobile = $row[5];
$email = $row[6];
$address = $row[7];
}
?>
Post.php中加入:
$action = 0; //传来的动作,默认为添加记录,0:添加 ; 1:修改
$id = $_GET['id'];
if($_GET['action']!=null)
$action = $_GET['action'];
....
else if($action==1)
{
$sql = "UPDATE `mydb`.`addrlist` SET
`Name` = '$name',
`Sex` = '$sex',
`Birthday` = '$birthday',
`QQ` = '$qq',
`Mobile` = '$mobile',
`Email` = '$email',
`Address` = '$address'
WHERE Id = $id";
}
今天就到此为止,关于更多请看源码,源码我已经打包上传了
AddressBook 2010-4-25修改.rar
相关文档:
<?php
/**
+++++++++++++++++++++=+++++上传图片++++++++++++++++++++++++++++++++++++++++
—————————————————————————————&mdas ......
1 文件结构
|
|――images
|――include
|――parameter
|――config
|――function
|――index
images存放图片文件,include中是系统是要引用的文件,一般在parameter中存放参数文件,config中存放配置文件,function中存放方法文件,如javascript的方法等,并按功能模块的分类,将各功能的类也放入其 ......
如何用php直接调用文本文件内容:首先通过file函数打开服务器上的一个文本文件,返回的$myFile 就将成为这个文件操作的句柄,然后再通过循环指令,取出文件中每一行的内容并打印出来。
编程思路
首先要使用的函数为fi1e,本函数与 readfile() 类似,不同的地方为 file 函数将文件中的内容全部读出 ......
搞了很久。。终于发现原来是权限问题。。
2行命令搞定
grant all privileges on rogue.* to admin@localhost identified by 'admin' with grant option
grant all privileges on rogue.* to admin@'%' identified by 'admin' with grant option
经典了。。。
魔力私服网页端搞定咯~~ ......