I am using a text file as a database. This code only shows the row by the id I select. I want it to show everything from the text file.
<?php
$lines = file('database.txt');
$data = array();
$id = 1;
for($i = 0; $i < count($lines); $i++){
if($lines[$i] == $id){
$data[0] = $lines[$i];
$data[1] = $lines[$i+1];
$data[2] = $lines[$i+2];
$data[3] = $lines[$i+3];
}
}
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css" media="all" />
<title>Test</title>
</head>
<body>
<div class="box1">
<h1><?= $data[1]; ?></h1>
<img src="<?= $data[2]; ?>">
<p>
<?= $data[3]; ?>
</p>
<br />
<a href="<?= $data[4]; ?>">Click here!</a>
</div>
<div class="box1">
<h1><?= $data[1]; ?></h1>
<img src="<?= $data[2]; ?>">
<p>
<?= $data[3]; ?>
</p>
<br />
<a href="<?= $data[4]; ?>">Click here!</a>
</div>
</body>
</html>
and here is my database file
1
Name
Image
My text
Link
-------
2
Name1
Image1
Text1
Link1
-------
3
Name3
Image3
Text3
Link3
-------