Can anyone help me with writing a code for editing records previously entered in a MySQL database table, with the help of PHP? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anyone help me with writing a code for editing records previously entered in a MySQL database table, with the help of PHP?

So, I'm creating a webpage where I display the information of a user in a table by entering his/her ID. Now, I want to give the options like "edit" and "save" below the table, which will update and save the records stored in MySQL database accordingly.

17th Mar 2017, 6:24 AM
Keval
2 Answers
0
with the same mysql_query($query) you just need to run the mysql update: $query = "UPDATE tablename SET colname = "'.$newvalue.'" WHERE colref = ".$id.""; //$id for example, you can search by any col value. you can add more updates with commas SET colname = "'.$newvalue.'", SET colnameb = "'.$newvalueb.'"...
17th Mar 2017, 6:48 AM
Victor GS
Victor GS - avatar
0
And how do I take the new input from the user? should I take the user to a new page after clicking the "edit" button, and have him enter the info? and one more thing, I would like to display the already entered data in the table and have him append the data if he would like to...
17th Mar 2017, 7:24 AM
Keval