Dynamic load from sql and then dynamic save

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

rhondachurchill99

Thread Starter
Joined
Nov 28, 2020
Messages
1
I have a password protected weboage (internal company admin use only) that loads a row from sql using js, ajax and php. The webpage then displays the sql row but it also gets and displays the column names as these change over time. The user can then amend the values with the idea to save the amended row back to the sql.

What would be the best way to insert the data back again as normally I would use the column names in the sql insert but in this scenario the php script doesn't know what the column names are so it won't know where to put them. I could try and just write the row in the correct order (without column names) but worry it would get out of sequence and write to the wrong column. Can I somehow pass to the insert php script an array of the column names (maybe from the form label names) and values so that I can insert it dynamically to the correct columns? I don't know how to get this from the html form when I press submit as I only get the values and no indictaion which column they belong to.
 

colinsp

Colin
Joined
Sep 5, 2007
Messages
2,337
If I understand your requirement correctly (it isn't easy without a specific example).

Make sure that each row has a unique column such as record_id and then just use that as pointer on which row to update in the table. The record_id does not need to be displayed to your users just used in your code.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top