我在學校學到的是使用file_put_content()來輸入和顯示數據。但我無法弄清楚如何編輯/更新或刪除裏面的數據。PHP(編輯和刪除HTML文件)
我「form.php的」
<!--Form to the php script-->
<form action="foodscript.php"method="post">
I love:<br>
<input type="text" name="foodname" value="">
<input type="submit" value="Submit">
</form>
我輸入一些食品名稱後,它發送到文件調用「foodscript.php」
<?php
//This is where my input data is being process to the txt file.
$name= $_POST['foodname'];
//This is where my data would be store in this file.
$file= "foodhistory.html";
//The function is begins to created new file and store my data on it.
file_put_contents($file, $name . PHP_EOL, FILE_APPEND);
?>
那麼,foodhistory.html已創建並存儲我已在表單中輸入的數據。該數據被稱爲「壽司」裏面的foodhistory.html。
所以我的問題是如何編輯/更新或刪除我的數據「壽司」使用具有刪除和編輯按鈕的新窗體?如果你們有更好的想法該怎麼做,你介意讓我看看這個過程或方法嗎?我只是一個學生。
很多謝謝。
不要將數據存儲在HTML中,將其存儲在數據庫中。您可以在那裏編輯/刪除數據。鑑於這個問題,你真正應該從PHP/MySQL的一些教程開始。 – David
@大衛哦,我的學校還沒有教這個階段,但我想在網上找到它。 –
然後,您正在尋找的Google搜索詞是「PHP MySQL教程」。 – David