欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

用文本文件制作留言板提示(下)

 更新時(shí)間:2006年10月09日 00:00:00   作者:  
管理你的留言在文本文件中實(shí)現(xiàn)不如數(shù)據(jù)庫中那么方便,下面我們想辦法來實(shí)現(xiàn)這個(gè)效果!
在輸出的時(shí)候我們是用數(shù)組來保存數(shù)據(jù),那么我們會(huì)很方便地為每組數(shù)據(jù)按順序分配一個(gè)序號(hào),通過對(duì)這個(gè)序號(hào)來操作,我們就可以方便地修改數(shù)據(jù)!
$date[0]為文本文件中第一行,我們輸出時(shí)分配序號(hào)為0.
輸出時(shí)有這樣的效果:

<a href=”modify.php?Id=0'>修改留言</a>
我們?cè)俣ㄖ苖odify.php
<?php
if($id!=””){
$date=file(“txt/mytxt.txt”);
$str=explode(“&”,$date[0])
?>
<form method="post" action="modify.php" onsubmit="return check()">
  <input type="text" name="tech1" value=<?php echo $str[0];?>>
<input type="text" name="tech2" value=<?php echo $str[1];?>>
<input type="text" name="tech3" value=<?php echo $str[2];?>>
  <input type="submit" name="Submit" value="Submit">

</form>
<?php  
}else{
$str=$tech1.”&”. $tech2. ”&”.$tech3….
If($str!=””){
//將修改后的數(shù)據(jù)寫回文本文件!
}
}?>

在這個(gè)過程中要注意保持$id的值不丟失,在寫回?cái)?shù)據(jù)時(shí)先將文本中的值讀入$date,再$date[$id]=$str;
$fp=fopen("txt/mytxt.txt","w");
fwrite($fp,$date);
fclose($fp);

相關(guān)文章

最新評(píng)論