Jump to content

[SOLVED] Txt Database.


DeathStar

Recommended Posts

Edit: Fixed

 

Used list and explode to extract data.

 

hello.

 

I am trying to figure out how to make a script that reads from a .txt file and displays data from it, liek a database.

 

the values is stored liek this:

440408,TH0rn,258,1,68,2853
250983,m0f0kiss,0,1,80,1072
270181,PsykoNinja,8,1,67,3103
539930,iajamo,127,1,73,2216
332802,luk3y,14,1,67,3104

 

Any help in doing this?

 

My best attempt is:

<?php
$get_name = 'DeathStar0'; 
echo '<table><tr><th>Name</th><th>x</th><th>y</th><th>Points</th></tr>';
$lines = gzfile('http://thedomain.com/file.txt.gz');
if(!is_array($lines)) die("File could not be opened"); 
foreach($lines as $line) {
list($id, $name,$x, $y, $player, $points, $rank) = explode(',', $line);
$name = urldecode($name);
$name = addslashes($name);
if ($name = $get_name){
echo '<tr><td>'.$name.'</td><td>'.$x.'</td><td>'.$y.'</td><td>'.$points.'</td></tr>';
exit;

}
}
echo '</table';
?>[/code[

Link to comment
https://forums.phpfreaks.com/topic/53913-solved-txt-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.