Need help with PHP script (very easy for programmers)

IntensE

Power Member
Joined
Aug 19, 2008
Messages
771
Reaction score
661
Hello, I need to make a page like this one: http://mnemotechnics.org/3.1415926/t/words3.php

But I need to do it with words in a different language and also input the number of words to display.

So far, I made this code:

Code:
<?php  
$filename = $_SERVER["DOCUMENT_ROOT"].'/test/words.txt'; 
$number = $_POST['number'];
if ($fileContents = file($filename)) { 
 shuffle($fileContents); 

?>

<form action="." method="POST">
<br><br>How many words to show? <input type="text" name="number"><br>
<input type="submit" value=" Enter ">
</form>

<h2>List of words:</h2><br >
<?php
for ($i = 0; $i < $number; $i++) { 
  print($fileContents[$i]. '<br />'); 
 } 
} else { 
 die('Could not get contents of: ' . $filename); 
} 

?>

This code displays the words ok, but they are not in a list and I need to make it like the website above with words numbered like:
1. word1
2. word2
3. word-etc

Any help ?
 
you need to break out into HTML you have already done this in your code with
'<br />'

so you just need to put in a <ol> ordered list in your PHP code
you already have a looping for statement you just need to add your HTML elements
 
thanks a lot, I figured it out !
 
Back
Top