This is what I want…
I have a couple of .txt files:
1.txt
2.txt
3.txt
Now i want to make a website with tree buttons and when I click on the first the txt from 1.txt is shown on the screen. When I click on the second the text of 1.txt is still there en the text of 2.txt is shown above it. Can someone help me!!
I’m trying to do this by calling the PHP function from HTML without refreshing it.
This is what I have for now…
<html>
<head>
<title>Update</title>
</head><body>
<a href="" call inputText("tekst1.txt")>tekst1</a>
<a href="" call inputText("tekst2.txt")>tekst2</a>
<?PHP
function inputText ($vileName) {
$filename = $vileName;
$text = "";
$contents = @file($filename) or die("No files in guestbook.");
foreach ($contents as $line) {
$text .= $line;
}
$text = split("<break>", $text);
$text = array_reverse($text); # removing this line will put newest comments at the bottom
for ($i=0; $i<count($text)-1; $i++) {
echo "<div style=\"border: gray 0px solid; padding: 0px; font-family: arial, sans-serif; background-color: #ffffff;\">";
echo $text[$i];
echo "</div>";
}
}
?>
</body>
You can’t call a PHP function from HTML. PHP is a server-side language, so it runs on the server - not in the browser.
You should use JavaScript instead as that runs in the browser. Unfortunately you don’t have access to the text files on the server then, but you can get around that by including the text from the files in the JavaScript code.
I already tried this but this removes the text that was on the screen before because the page is reloaded. What I want is that all the txt stays on the screen so when you click button 1,2,1,2
You see the text 2,1,2,1