Sorry but I am stumped, I have written a php program that uses a form to submit the fields that are written into the record of a file, and it writes those records just fine. Now I want the same program to be used to retrieve the MYSQL table row to be changed but not sure how to go about it. Before I get started down the wrong path, can I just execute some php code before the page is loaded, to qry for the record that I want to maintain, and since my fields are the exact names from the form that are in the row, will they just come up in the form and then they can be changed and the submit will update the table instead of do an insert? Or do I have to move all of the row fields one at a time into $formvars[...] to get them connected to the form?
Any words of wisdom or samples to follow? This is actually a file maintenance program to create a 1 record table of control fields. So is there a simple way to display a form, create the table and insert the 1 row, then using the same program retrieve that same row and put the fields into the form the changed then with submit rewritten back to the table row?
They won't magically appear. You would, as you said, do the query at the start of the page load, then you can use php to set the default values of the form:
echo '<form method="post" action="whatever">';
echo '<input type="text" name="username" value"' . $username . '">';
and so on. Obviously you'll have to deal with different input elements in different ways, but all you're doing is using PHP code to set the default values for each of the HTML form elements.
I'll be interested to see if those with more knowledge have any quick ways to achieve this.
This topic is now closed. New replies are no longer allowed.