0

I got a text field for entering the new categories and submit with ajax ..

My script is working but everytime i submit new category mysql is creating one row to hold single category name .

I would like to create something like this eachtime when i add a new category the same single row should get updated

Id.   User id.   Category
 1.      23.          Personal , shopping , others +

So everytime i update a category name the row should be updated with the comma separated value . And also i would like to fetch the result in a select box

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
  • use IODKU (insert on duplicate key update). Or use insert ignore – Drew Sep 22 '15 at 17:50
  • Here is a complete walkthru with schema and data results shown. [This link](http://stackoverflow.com/a/32468519/1816093) – Drew Sep 22 '15 at 17:53
  • Why would you want to store multiple values in that single column? From the looks of your table, you have a schema that will allow you to store an infinite amount of categories for any given user as a new row because ID is your primary key, as opposed to User id. Now, if you want to return you're data from a query in the form that you have above, you can SELECT with a GROUP_CONCAT and throw your GROUP BY at the end using User id. have a look here. https://en.wikipedia.org/wiki/Database_normalization – Nathan Sep 22 '15 at 17:58

0 Answers0