Вывод:
$file_pointer = fopen("data.txt", "r");
$content = array();
while (!feof($file_pointer)) {
$content[] = fgets($file_pointer);
}
foreach ($content as $item) {
$row = explode("|", $item);
echo
"<tr>
<td>
<img src='$row[4]' alt='$row[0]' />
</td>
<td>
<p>$row[0]<p/>
<p>$row[1]</p>
<p>$row[3]</p>
<p>$row[2]</p>
</td>
</tr>";
}
fclose($file_pointer);
Запись:
<?
if(isset($_GET["submit"])) {
$game = trim($_GET["game"]);
$price = trim($_GET["price"]);
$year = trim($_GET["year"]);
$plat = trim($_GET["plat"]);
$img = trim($_GET["img"]);
$input = "\n".$game."|".$year."|".$price."|".$plat."|".$img;
$filePoitner = fopen("data.txt", "a+");
fwrite($filePoitner, $input);
fclose($filePoitner);
}
?>
<form action method="get">
<input type="text" name="game" placeholder="Video Game"/>
<input type="text" name="price" placeholder="Price"/>
<input type="text" name="year" placeholder="Release Year"/><br/>
<input type="radio" name="plat" value="MULTIPLATFORM" checked/>Multiplatform<br/>
<input type="radio" name="plat" value="PS4" />PS4<br/>
<input type="radio" name="plat" value="XBONE"/>XBox One<br/>
<input type="radio" name="plat" value="PC"/>PC<br/>
<input type="text" name="img" placeholder="Box Art URL"/>
<input type="submit" name="submit" value="Submit"/>
</form>