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
https://forums.phpfreaks.com/topic/80491-solved-txt-database/
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
https://forums.phpfreaks.com/topic/80491-solved-txt-database/#findComment-408059
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
https://forums.phpfreaks.com/topic/80491-solved-txt-database/#findComment-408206
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.