Jump to content

Recommended Posts

hello guys

 

i heard there is a way that you can make something like a database on a text editor and when ever u want to change the info you just open a text editor and change the information

 

 

How is this called? where can i find a tutorial? any tips? thanks you very much  :)

Link to comment
https://forums.phpfreaks.com/topic/222824-fetching-info-from-txt/
Share on other sites

Check out phpmyadmin, I believe that's what they were referring to. There are others out there, this generally comes with most hosting services, and is installed by default with WAMP or XAMP. It's not from a text file, but it provides a user interface for changing your database information/structure.

hello guys

 

i heard there is a way that you can make something like a database on a text editor and when ever u want to change the info you just open a text editor and change the information

 

 

How is this called? where can i find a tutorial? any tips? thanks you very much  :)

 

Why do you want to do this?

Hello, Thanks for all the responses, i do have mamp, i do know what phpmyadmin is etc,

But i have seen there is a way you make a textfile a database and you can just change the content from the .txt

 

i want to do this because its a easier way to manage a website, just open up the .txt and change the content

instead of having to go to phpmyadmin etc :)

i want to do this because its a easier way to manage a website, just open up the .txt and change the content

instead of having to go to phpmyadmin etc :)

 

Trust me, creating a relational database is well worth it and a lot easier.  Their purpose is to store data.

Hello, Thanks for all the responses, i do have mamp, i do know what phpmyadmin is etc,

But i have seen there is a way you make a textfile a database and you can just change the content from the .txt

 

i want to do this because its a easier way to manage a website, just open up the .txt and change the content

instead of having to go to phpmyadmin etc :)

 

So I assume you're talking about flat-filing your website instead of using a database completely? Trust me even if databases seem intimidating, databases in the long haul will be so much better  for most cases.

I totally agree with the consensus that a real db is the way to go; that said here is a simplistic example of 'flat file db'.

 

Step 1. determine what information you will be storing - for this example a very simple address book. These are like fields in a real database

first name

last name

street address

city

state

zip

telephone

cellphone

email address

comments

 

Step 2. determine what character you can safely use to separate (delimit) the 'fields' - because names, addresses, comments might contain apostrophes or commas or spaces, a safe bet is the pipe |.

first name|last name|street address|city|state|zip|telephone|cellphone|email address|comments

 

 

Step 3. each line represents a 'record', all records are in the same order and are tenimated with the newline character \n.

if you accidentally add a newline/carriage return to a "field's" content you WILL have problems.

 

Step 4. Adding to the file can be accomplished via a text editor.

 

Step 5. Accessing the file and records via php.

  $lines = file($name_of_the_text_file);

this will put all of the lines from the text file into an array.

to access the individual 'fields' of the line, you need to convert the line into a new array.

  $line_array = explode("|", $lines[0]; 

to display the telephone number you would...

  echo $line_array[6];

 

If there will be VERY limited amounts of information, yes a flatfile can be 'easy' to use. The downfalls come when searching, deleting, updating, sorting and many other tasks.

 

Also, making a page/form/function that allows you to add/edit/delete/etc information in/from a real db is not difficult and does NOT require you to 'access' phpadmin.

 

Make sense?

 

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.