php - EDIT/UPDATE comma separated values into mysql rows and add new
EDIT/UPDATE comma separated values into rows and add new
I am trying to edit products with ajax in different rows then update and add new rows from a form creating dynamic fields using the same name[]
but dont know how to pull them to edit them then update them in the same spot since they are in different rows and tables where i need updating
the only way i can think of editing them is like this example http://www.infotuts.com/ajax-table-add-edit-delete-rows-dynamically-jquery-php/ but this is using the 1 row for every line and i have products in different rows
dont know if should edit them live like this, but how would i pull the old rows and add new rows as well linked to the same order http://www.aquim.com/web-article-229.html
I was trying to edit them then update them something like, But how do i update the old products as well as adding new products and linking them to the different tables
EDIT FORM
product 1 [product 1 row] [price 1] [quanity 1] [total 1]
product 2 [product 2 row] [price 2] [quanity 2] [total 2]
then with a form add new products
SELECT OLD PRODUCTS AND UPDATE THEN GET ID AND ADD NEW PRODUCTS AND LINK TO TABLE
The only way i thought about probably doing the updating is erasing everything and reinserting it but i assume that would cause a clash in the future if multiple people are doing it
{-code-2}
| quoteID | bid_name | status | total |
|
Answer
| 1 | bid1 | pending | 100 |
| 2 | bid2 | stuff_y | 200 |
| quoteID | productID |
|
Answer
| 1 | 4 |
| 1 | 4 |
| 2 | 5 |
| 2 | 5 |
| productID | product_name | price | quanity | bid_name |
| 4 | pro_1 | price_1 | quan_1 | bid_1 |
| 4 | pro_2 | price_2 | quan_2 | bid_1 |
| 5 | pro_3 | price_3 | quan_3 | bid_2 |
| 5 | pro_4 | price_4 | quan_4 | bid_2 |
Answer
Solution:
You could Pull --- Check --- Update --- Delete
Psudo Code, Non-working! This is to show the flow:
There may be a better way to do this... This is how I did it when I encountered this problem a while ago.
Answer
Solution:
to pull the products
}
to update them depends on how you are updating them I am updating them using the serialize function and some custom data
to get the ids, i use javascript to push them in an array
to delete them first
productID='$deleteold' ";
then update
get the id to see if it matches any of the ids submitted
// for this depends how you are submitting it, i am doing it ajax for ( $for =0; $for < count($data['productName']); $for++) {
then inside the for lopp we check if the ids match any of the current products
I exploded an array i had submitted, easiest way i thought of doing it, then just do a count inside so it can loop