以下是php程序部分
<?php
require_once("conn_inc.php");
require_once("smarty_inc.php");
if ($_GET['id']) {
$id=$_GET['id'];
$query=mysql_query("select * from news_list where id='$id'");
$row=@mysql_fetch_array($query);
$array[]=array("id"=>"$row[id]","name"=>"$row[name]","pass"=>"$row[pass]","mail"=>"$row[mail]","content"=>"$row[content]");
}
if ($_REQUEST['submit']) {
$aFaid=$_REQUEST['into'];
$query_update=mysql_query("update news_list set name='$aFaid[name]',pass='$aFaid[pass]',
mail='$aFaid[mail]',content='$aFaid[content]' where id='$id'");
if ($query_update) {
echo "<script>alert('更新成功!')</script>";
echo "<script>location.href='list.php'</script>";
}else {
echo "shib";
}
}
$smarty->assign("title",$array);
$smarty->display("list_update.tpl.html");
?>
以下是smarty部分程序
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form action="" method="POST">
<table align="center" width="70%" border="1">
{section name=list loop=$title}
<tr >
<td width="100">用户名</td>
<td ><input type="text" name="into[name]" value="{$title[list].name}" size="50"></td>
</tr>
<tr>
<td>密码:</td>
<td ><input type="text" name="into[pass]" value="{$title[list].pass}" size="50"></td>
</tr>
<tr>
<td>电子邮件:</td>
<td ><input type="text" name="into[mail]" value="{$title[list].mail}" size="50"></td>
</tr>
<tr>
<td>内容:</td>
<td ><textarea name="into[content]" cols="40"rows="15">{$title[list].content}</textarea></td>
</tr>
<tr>
<td colspan="2"><center><input type="submit" value="提交" name="submit"></center></td>
</tr>
{/section}
</table>
</form>
</body>
</html>
大家看了提点建议,我接着smarty时间不长,谢谢各位同行!