Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script strategy 1

Status
Not open for further replies.

cian

Technical User
Oct 11, 2001
1,383
Hi guys,

i'm starting work on a new script, I haven't started on the code yet because I want to figure out the strategy to take so I hope you can advise me.

basically it's like a book mark script.
I've desiged the look so that the links are listed with an icon in a 3 column table such as the following:

|icon|link|spacer|icon|link|spacer|icon|link|
|icon|link|spacer|icon|link|spacer|icon|link|

There are 2 problems I can't figure out.

1. how to add new links.
When a new link is added it needs to either add to an empty table cell in an existing row always if available or else create a new row and add the link to the first cell.
To make it worse i'm using flat files to store the data which I gues makes it more difficult.

I presume I can just store the data like:

|id number|icon name|link address|link title|...next 2 cells

what about the html code, is it easier to write this also to the flat file?

2. Editing/deleting links
When editing links I presume I just search the flatfile for the id number and display the information in form fields to be edited?
Same for deletions I just search for the id number?
Main question is how do I associate the id number with a particular link? When calling the data from the flat file do I just use a name or id attribute to identify the icon and link?

But then I need to re-organise the date back into 3 columns? I don't want to end up with a chess board look with
empty cells.


What do you think? Sorry for the hundred questions!





- É -
 
Do you have a database available? If so, it can make entry management a lot easier.

If you are going to use a flat file, I don't understand your table structure. Why do you say it's three columns when your example shows seven? Are you trying to store layout positioning in the flatfile, too?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Hi sleipnir214[/]

I will probably make a database version also but if I plan to offer it for download then it has to work with flat files.

The visual layout was originally 3 columns, sorry for misleading you, so the table layout would be 7. I have changed it slightly but it should still be 7 columns.

Layout positioning - i was wondering would it be best to store the positioning in the flat file but I guess it would be easier not to do do?

What do you think? If I can figure out question 1 it will probably answer question 2, i hope :)






- É -
 
Editing flat files is problematic in a multiuser environment, which a web site is.

You have to ensure that any user's instantiation of the script does not interfere with the editing of the file that another user is performing. This is the reason I suggested a database server -- it can handle that for you nicely.

One way to handle adding a link is to either append to the file or to read the entire file, insert the new link the appropriate place, and rewrite the file. You can either read the "old" file into memory and perform the edits there or stream the "old" file to a "new" file, adding the link where appropriate. But keep in mind you're going to have to lock the file to keep other instantiations of the script from interfering. Something like PHP's flock() function will probably be useful.



Want the best answers? Ask the best questions: TANSTAAFL!!
 
Hi,
thanks for the advice, i was planning to use flock just in case it's necessay but the plan was this would be a 1-user script, guess I better plan for multiple users though.

Thanks again, i'll give your ideas a try.



- É -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top