Sebolains Posted December 6, 2007 Share Posted December 6, 2007 Hello, I am currently working on a very simply php page. I need to create a database of about 300 entries with 4 or 5 fields for each entry. I refuse to use mySQL because I simply hate it. I know it is also very possible to use a .txt file to do so. The file would look sth like this: 115|Name of File|Description of File|External URL I was wondering if someone could explain me how to do this (with a simple example or sth) or give me the link to a good tutorial. Thank you a LOT to who ever can help me Quote Link to comment Share on other sites More sharing options...
therealwesfoster Posted December 6, 2007 Share Posted December 6, 2007 Reading and Writing: http://www.apitalk.com/document.php?id=1184208074_5 Then, learn the explode function ( http://php.net/explode ) in order to retrieve and divide the information Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 6, 2007 Share Posted December 6, 2007 There is a whole flat file database forum section that probably has working examples in it - http://www.phpfreaks.com/forums/index.php/board,36.0.html Quote Link to comment Share on other sites More sharing options...
Sebolains Posted December 6, 2007 Author Share Posted December 6, 2007 That tutorial was almost useless because it had no example. I did not get anything. Please could anyone give me a better tutorial or explain further? Thanks a lot. Quote Link to comment Share on other sites More sharing options...
shocker-z Posted December 6, 2007 Share Posted December 6, 2007 <?php $file= 'E:/liam/resourcedisks/test.txt'; $handle = fopen($file, 'r'); $Data = fread($handle, 8192); fclose($handle); $lines=explode("\n",$Data); foreach ($lines as $line) { list($ID, $filename, $description, $url)=explode('|',$line); echo 'URL: '.$url.'<Br>'; } ?> try that, off home so left the code short... Liam Quote Link to comment Share on other sites More sharing options...
trq Posted December 6, 2007 Share Posted December 6, 2007 You might also be interested in the sqlite extension. It is what it says, a lite sql database. Its really really quick too! Quote Link to comment Share on other sites More sharing options...
Sebolains Posted December 6, 2007 Author Share Posted December 6, 2007 <?php $file= 'E:/liam/resourcedisks/test.txt'; $handle = fopen($file, 'r'); $Data = fread($handle, 8192); fclose($handle); $lines=explode("\n",$Data); foreach ($lines as $line) { list($ID, $filename, $description, $url)=explode('|',$line); echo 'URL: '.$url.'<Br>'; } ?> try that, off home so left the code short... Liam Thanks a lot! that worked perfectly. I have a new request though: how do I get the information of the hole line according to the ID for ex: I want to be able to show the name desc, etc of the line with id nº 113. How do I do that? THANKS A LOT for what you've done until now!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.