Well I am going to begin writing an archive system, but before I do that I had to think about the process that I would have to use to get it to work. My first thought was use a database to store all of the information. Well I don't have another database to work with. So my question is, is there a simpler method to doing it than below.


First create a folder for every section that i plan to have in the archive. Then when the user submits a folder I take the data that was entered in the form and I store it into some sort of file. Then when someone actually wishes to view the archives I just run a loop through the file and then display everything.

Because I know i will probably have questions about my code i will also plan on using this thread to post those questions as well.
Make a textfile database...

just file() the thing to read it into an array, and you can search it easy enough... it'd probably be easier...
That is the direction that i was leaning. Now that i know it would be easier i guess that is what i will do.
right... and you can have arrays in each line like

filename,category,description,etc,etc,screenshots,etc

Just don't forget to comment out whatever separator you use Wink
yeah.

Wouldn't it be easier to use a Database though?
rivereye wrote:
yeah.

Wouldn't it be easier to use a Database though?


I find it is often the opposite. By using a 'native' array you gain access to ease of use and 'native' function support such as for searching. A database, however, will likely be faster and limits the need to do some reinventing of the wheel, per se, and a database allows for more flexibility.

Laffer: An idea would be to have a per-folder directory index instead of a global database. As in rather than having a single file that contains a list of all the files and what categories or "virtual folders" (such as TI-83 ASM), you have all the different files in physically different folders (named per category and then per subcategory) with an index file that then provides the metadata for each file. Since you are reading the 'database' from a file, this should be faster to read and to update, although you lose the ability to have the same file in multiple categories.
So you are saying that from my main folder if i have the sections computer, ti-83 and ti-83+, then i should have a folder for each of those. And if i plan to categorize even further have another folder withing each of those for the new category. Then each of those folders have a page that displays everything and a file that holds the data about everything being updated.
something like that. I was more thinking you have one PHP script (lets call it archive.php for now), and one of the arguments it takes is the path you want it to be looking in. For example:

<domain>/archive.php?cwd=/ti83/asm/games

and your physical folder structure would mimic that of the 'cwd' argument (cwd == current working directory). Then the archive.php script opens up some sort of index file in that directory which contains all the needed metadata (name, author, rank, etc...) for each file.
Okay. I know what you mean now.
After doing some more thinking i have now figured out which functions i will need to make this much easier. The functions i am planing on using are:

fopen()
fclose()
file_get_contents()
explode()

With those functions i plan on opening the file. Then use file_get_contents() to write its contents from the array. Then using a for loop go through the array and write each element to another variable. Then i will use the explode() function on that variable. Once i do that i will then display the information. And repeat.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement