// 程序开始 $db = mysql_connect("localhost", "root");
mysql_select_db("study",$db); // 判断是不是修改文件 if ($submit) {
$sql = "UPDATE wenzhang SET timu='$timu',zuozhe='$zuozhe', laiyuan='$laiyuan',textt='$textt' WHERE id=$id";
// 向数据库发出SQL命令
$result = mysql_query($sql); // 文章生成 $t = date("Y-m-d h:i:s"); $muoban1 = fopen("muoban1.txt","r"); $muoban2 = fopen("muoban2.txt","r"); $muoban3 = fopen("muoban3.txt","r"); $qita = "
作者:$zuozhe ??来源:$laiyuan ??时间:$t
|
"; $muoban4=fread($muoban1,1000); $muoban5=fread($muoban2,1000); $muoban6=fread($muoban3,1000); fclose($muoban1); fclose($muoban2); fclose($muoban3); $main="$muoban4 $timu $qita $muoban5 $textt $muoban6"; // 文章生成 $ttt=".html"; $n=$id.$ttt; $f = fopen($n,"w"); fwrite($f,$main); fclose($f);
echo "记录修改成功!";
}
// 我们是否进入编辑修改状态 if ($id) {
// 我们是在编辑修改状态,因些选择一条记录
$sql = "SELECT * FROM wenzhang WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$id = $myrow["id"];
$timu = $myrow["timu"];
$zuozhe = $myrow["zuozhe"];
$laiyuan = $myrow["laiyuan"];
$textt = $myrow["textt"];
// 显示id,供用户编辑修改
$fom1=" "; echo $fom1; } if (!$id) {
// 如果不是修改状态,则显示员工列表
$result = mysql_query("SELECT * FROM wenzhang",$db); printf(" "); while ($myrow = mysql_fetch_array($result)) {
printf(" - %s n",
$myrow["id"], $myrow["timu"]);
printf("(修改)
", $PATH_INFO, $myrow["id"]);
} printf(" "); } // 程序结束 ?>
|