Hello,
I have a small problem i need help with:
I have built a small database, text-based. Every entry is devided by a \"|\", and every single line presents a whole submission.
For example:
3254443|Craig David|Fill Me In|4MB|Unknown|MP3|160|4
7896342|Uncle Kracker|Follow Me|3MB|Pop/Rock|MP3|128|2
and so on...
The code bellow prints the 15 latets submissions, counted from the bottom of the text-file. This works fine, but I want it to randomly print 15 submissions, from the whole database (textfile), not the 15 latets. And everytime you reload the page, it should print another 15 (randomly chosen) submissions. Can someone who understand what I mean please help me to change the code below, so it works like this?
With submission i mean every complete line, \"3254443|Craig David|Fill Me In|4MB|Okänd|MP3|160|4\", and so on...
<?
$rakna = count(file(\"database.txt\"));
$data = \"database.txt\";
if (file_exists($data))
{
$bo = 15;
$cp = $rakna - $bo;
$afilen = file($data);
$ko = 0;
for($num = $cp; $num < count($afilen); $num++)
{
$ko++;
$bfilen = explode(\"|\",$afilen[$num]);
echo \"<img src=images/arrow.gif><b>$ko</b> <a href=download.php?file=$bfilen[0]>$bfilen[1] - $bfilen[2]</a><br>\";
}
}
else
{
echo \"<tr><td>Couldnt open database.</td></tr>\";
}
?>