我有一些数据的文本文件加载输入数据所做的更改,那我传递到一些投入的形式提交从文本文件
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form action="edit_subjects.php" method="post">
<?php
$content = file('../db/test.txt');
foreach($content as $eachLine) {
list($subject, $type, $description) = explode('|', $eachLine);
echo '<label for="subject">Subject:</label>';
echo '<input type="text" name="subject" id="subject" value="'.$subject.'"><br>';
echo '<label for="type">Type:</label>';
echo '<input type="text" name="type" id="type" value="'.$type.'"><br>';
echo '<label for="description">Description:</label><br>';
echo '<textarea name="description" id="description">'.$description.'</textarea><br>';
}
?>
<input type="submit">
</form>
</body>
</html>
运行代码给出了这样的输出:
<label for="subject">Subject:</label>
<input type="text" name="subject" id="subject" value="Subject 1"><br>
<label for="type">Type:</label>
<input type="text" name="type" id="type" value="Type1"><br>
<label for="description">Description:</label><br>
<textarea name="description" id="description">Description1
</textarea><br>
<label for="subject">Subject:</label>
<input type="text" name="subject" id="subject" value="Subject 2"><br>
<label for="type">Type:</label>
<input type="text" name="type" id="type" value="Type2"><br>
<label for="description">Description:</label><br>
<textarea name="description" id="description">Description2
</textarea><br>
<label for="subject">Subject:</label>
<input type="text" name="subject" id="subject" value="Subject 3"><br>
<label for="type">Type:</label>
<input type="text" name="type" id="type" value="Type3"><br>
<label for="description">Description:</label><br>
<textarea name="description" id="description">Description3
</textarea><br>
正如你所看到的名字一遍又一遍的去,所以我怎么会单独访问每个组输入,并将其写入文件
你会这样做edit_subjects.php - 或者这是一个自引用形式? – hammus
我明白我会做edit_subjects.php,但我不知道该怎么做 – svendjokumsen
好的一秒钟,我会发布一个解决方案 – hammus