Jump to content

[SOLVED] txt database


Sebolains

Recommended Posts

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 :)

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

<?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!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.