Ok this what I am trying to do. I have looked but can't find a good tutorial on how to do this. Here it is.
I am building a web page that the user can access to update portions of their site. One particular spot is a scrolling text box that displays lines from a javascript file which the user does not edit the actual javascript, just the line that they want displayed. I have it set up so that the user can write to this file, but I also want the user to be able to delete or edit a line in the .js file. Basically this is how I want it set up:
The user enters the data and submits it. When they go to a dedicated page they can see the line they just wrote along with the other lines that have already been written. Each one should display 'delete | edit'.
Sure, just not a real easy one. I've done this with CSV files. The .js file is a flat file -- thus, you cannot just insert or delete lines in the middle of it. Two ways -- all based on sequential line number (or a line tag which is part of the data): Read it all into memory and write it all out -- including or minus the inserted, updated, or deleted lines. Or, read a line at a time from one file and write a line at a time to a new file -- including or minus the inserted, updated, or deleted lines -- then delete the old file and rename the new file back to the old file name.
That was pretty simple, actually. You could read the file (to an array) a line at a time until you found the line before or after which you wanted to add another line. Then, you'd add it to the array and continue reading. Once you reached the end of the file, you could pump it all back out to a different file, then delete the original and rename the new one to the same name.
Why do you want to do things with Javascript, anyway?
I am wanting the values to be user selected using a form. I add this to the script:
PHP Code:
$name1 = $_POST["fruit"];
$number1 = $_POST["fnumber"];
.
.
.
$query = "INSERT INTO fruit (name, number) VALUES('$name1', '$fnumber1')";
This you would think is the same thing but the first example adds it ok, the second adds a field but nothing there. Even adding the double quotes does not work.
Bookmarks