开发者

MySQL: Storing a value from a field that may show up variable times on a form

开发者 https://www.devze.com 2023-02-03 23:14 出处:网络
I\'m creating a form in CodeIgniter that has a paired value- Companies, and CEOs.The idea is, while there is only one Company field with one CEO field below initially on the form, there is a button fo

I'm creating a form in CodeIgniter that has a paired value- Companies, and CEOs. The idea is, while there is only one Company field with one CEO field below initially on the form, there is a button for me to create more pairs of Company-CEO fields. I have an idea for how to make that appear on the frontend, but I'm not quite sure which is the best way to store it on the backend.

I think in order to combine each Company and CEO field into one value for storing in the MySQL database, I could simply use CONCAT. However, I'm not sure if I sho开发者_如何转开发uld even bother creating such a value. In any case, how would I handle the fact that there are a variable number of Companies (and thus CEOs) for each record? Would I have to store Company and CEO within another value? How could such an array or tuple be handled in MySQL?


Point 1: Do not combine the values. It will give you headaches in code splitting and combining. Make two columns, one for company, one for CEO.

Point 2: In general, when using a database, any time you have a list it gets its own table.

The various JS libraries out there let you handle this with a grid.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号