On Thursday, March 14, 2002, at 03:06  PM, Gav wrote:

> What I do want to do though is create a gallery feature so what I 
> believe I
> need to do is to append the info above into a textfile named total.txt 
> or
> something.  So that everytime a separate file is saved on to the server,
> it's info is added to this total file.  Is this the way to go about 
> it?  Or
> is there a php function that can see what files are in the directory, 
> open
> them and then use the info that way?
>
> I was told that a database is the way to go but I have no experience of
> these at all.

A database will help you to keep data in separate "entities" (by keeping 
X information in an X_info column, Y information in a Y_info column, for 
example).  A database is also very fast.  Database knowledge is also 
worth having on your resume.  I recommend you download MySQL, an 
easy-to-use and free relational-database-management-system.  No doubt 
you've seen a lot of references to it from PHP stuff, because the two 
are practically hand-in-hand partners.  If you can afford a book, get 
"MySQL" by Paul DuBois from New Riders books, and read the first chapter 
to get a feel for how the SQL language works (so you can write SQL 
statements into your PHP code).  Later when you have more time, finish 
the book, it's an excellent reference for the MySQL database system.  If 
you don't want to spring for the book but are still interested, there 
are a million tutorials on using MySQL.

But a whole database just for this one script seems to me to be some 
serious overkill.  I recommend that you keep your data in an XML file 
instead -- this is actually really really easy, probably easier than 
using MySQL, but not as fast or as powerful for doing queries or 
searches.  But you can mark up the data to keep entities separate, and 
append new Flash objects' data to a "master" XML document like you 
describe.  When someone wants to view the "gallery", just parse the XML 
file, or run it through an XSLT style sheet or something.  If you need 
to add to the gallery, just read the XML file into memory, insert the 
new XML code for whatever it is you need to add, and write it back to 
the file.  The PHP XML functions are at 
http://www.php.net/manual/en/ref.xml.php and there are tutorials at 
DevShed, SitePoint, and a dozen other excellent web support sites.

Either a database or XML can do what you want, it's really up to you.  I 
think the XML way will get you your results soonest, but learning MySQL 
will have a long-term value if you ever intend to do any back-end work 
or just want to know more about databases.  It's fun stuff.


Erik



PS: you can combine XML and MySQL to achieve some really powerful data 
storage tricks, though sometimes it's overkill to do so (depending on 
the extent of your project).







----

Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to