//更新数据库记录语句:update imooc_admin set username = 'king' where id =1
function
update(
$table
,
$array
,
$where
=NULL){
//遍历数组取出数值
foreach
(
$array
as
$key
=>
$val
){
if
(
$str
==null){
$sep
=
""
;
}
else
{
$sep
=
","
;
}
}
$str
.=
$sep
.
$key
.
"='"
.
$val
.
"'"
;
$sql
=
"update{$table}set{$str}"
.(
$where
==null?null:
"where"
.
$where
);
mysql_query(
$sql
)
return
mysql_affected_rows();
//mysql_affected_rows() 函数返回前一次 MySQL 操作所影响的记录行数。
}
请问里面的$str哪里来的,还没定义就能开始判断是否为空了?????
KevenHuang
雪颲