views:

62

answers:

1

Problem:

I dont know the simplest way to allow a single web viewer to update data in a text file on a server. (ie. only 1 person will be changing the data.)

Objective:

To make a prototype web application just one person needs to input in the start and end dates of new assignments and locations of staff and the whole company can visualize the information on a GANTT chart, probably using this Jquery libary.

Contraints:

  1. My data is about the equivalent size of 1000 of these javascript list of lists like

    data = [["John Smith" , "assigment" , "1/1/10", "1/1/11", "Peru"],[...],...]

  2. Employee assignment data must be on an internal server.

  3. I can't use a database (such as SQlite or MySQL).

  4. I can only use PHP, Javascript, and Jquery.

  5. Fact: Javascript cant directly change a data file sitting on the server.

My Tentative Fuzzy Solution:

On client-side: use jqeury getJSON() to pass the data back and forth between dataReadWriter.php.

On server-side: dataReadWriter.php modifies a PHP array as well as writes modified data and reads JSONdata.txt stored in a text file on our internal server.

+1  A: 

Given the constraints, it can't be done a lot smarter than what you are suggesting. One thing though, you shouldn't overwrite the only file containing the data, at least switch back and forth between two files, and make sure that your program does not overwrite the other file if one of the files show any signs of being damaged. You can use a PHP session to keep track of which file is the most recent, but better have some in-file timestamps as a fallback.

Is there anything in particular that you worry about?

eBusiness
@eBusiness Thanks. Is the reason I should use 2 files to ensure that 1 person does not overwrite another person's changes when they are overlapping one another in terms of reading and writing the file? To prevent overwriting each others changes I was thinking of giving permission to just 1 person to make changes. I am not sure I understand your question "Is there anything in particular that you worry about?" One worry is to make sure before I decide to start this that I dont burn too much time on this. Another worry is to ensure the code and data is simple for someone in future to use MySQL.
indiehacker
Primarily, it's to keep the data safe if the server crashes during a write. Of course a database application would take care of such stuff for you.
eBusiness