// 程序开始 $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"; // Article generation $ttt=".html"; $n=$id.$ ttt; $f = fopen($n,"w"); fwrite($f,$main); fclose($f);
echo "Record modified successfully ! ";
}
// Are we entering the editing state? if ($id) {
// We are editing and modifying the status, so select a record
$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"];
// Display id for users to edit and modify
$fom1=" "; echo $fom1; } if (!$id) {
// If the status is not modified, display the employee list
$result = mysql_query("SELECT * FROM wenzhang",$db); printf(" "); while ($myrow = mysql_fetch_array($result)) {
printf(" - %s n",
$myrow["id"], $myrow["timu"] );
printf("(modify)
", $PATH_INFO, $myrow["id" ]);
} printf(" "); } // End of program ?>
|