I am just out of interest messing around with PHP trying to make a form which will edit an entry in the database. would this be the right way to go about it?
What i've done is used the GET function to collect the ID of the entry then passed that into the form action URL " method="post">
and then with once the form is submitted the "editproducts.php" page collects the id from the URL and uses that to edit the correct entry.
Thanks :)
i'm pretty terrible at explaining myself so forgive me if its a hard question to understand
Hello, I also had some problems with making the entry in database. I am not good in coding, so i spent plenty of time trying to write it corrrectly, but I just wasted my time. I asked my friend who recently made a great personal web site, and he advised me to find a program that will build a form itself, as for me, I found phpforms, and now everything is ok.
The list is displayed somewhere. The URL has the ID of the entry in a get variable. In your page do a query to find all the info for that entry. the sql query would be something like SELECT * FROM YOURTABLE WHERE ItemID='$_GET['id']
Now run through the building the form inside a while loop. Use the while loop to fill in the form value fields.
Now in the update page, Collect all the variables and name them properly. Now clean up the variables (Lookup sql injection if you're not sure) Now update the table like UPDATE YOURTABLE SET field1='$field1', field2='$field2' WHERE ItemID='$_GET['id']
I am just out of interest messing around with PHP trying to make a form which will edit an entry in the database. would this be the right way to go about it?
What i've done is used the GET function to collect the ID of the entry then passed that into the form action URL " method="post">
and then with once the form is submitted the "editproducts.php" page collects the id from the URL and uses that to edit the correct entry.
Thanks :)
i'm pretty terrible at explaining myself so forgive me if its a hard question to understand
Just a quick bullet point list of things to do.
The list is displayed somewhere. The URL has the ID of the entry in a get variable.
In your page do a query to find all the info for that entry. the sql query would be something like
SELECT * FROM YOURTABLE WHERE ItemID='$_GET['id']
Now run through the building the form inside a while loop. Use the while loop to fill in the form value fields.
Now in the update page,
Collect all the variables and name them properly.
Now clean up the variables (Lookup sql injection if you're not sure)
Now update the table like
UPDATE YOURTABLE SET field1='$field1', field2='$field2' WHERE ItemID='$_GET['id']
And that should be that