简体   繁体   中英

PHP edit unique row in table

I currently have a PHP form that uses AJAX to connect to MySQL and display records matching a user's selection ( AJAX: Display MySQL data with value from multiple select boxes )

As well as displaying the data, I also place an 'Edit' button next to each result which displays a form where the data can be edited. My problem is editing unique records since currently I only use the selected values for 'name' and 'age' to find the record. If two (or more) records share the same name and age, I am only able to edit the first result.

Let's assume your file for editing is edit.php. Then, in the file where you generate the edit links, try changing your edit button link as follows:

 '<a href="edit.php?id="'.$row['ID'].'">edit</a>' 

Then you will be able to access ID variable as

 echo $_REQUEST['ID']; 

Note that the ID is case sensitive. Let me know how it goes.

when displaying records from ajax, also send the primary field(id in most cases) along with name and age

and when u are displaying these data along with edit incorporate that primary field with edit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM