开发者

How to make db structure for multiple input in MySQL and PHP

Below is my current structure for MySQL database

id | item_name  | item_files 
------------------------------------------
1  | Item A 开发者_如何学编程    | file1.zip,file2.zip,file3.zip
2  | Item B     | file3.zip 

Example I create simple form to fill up Item Name and Multiple upload files then store it to db.

Question :-

  1. How to design the db structure for accept the multiple files?
  2. There have a way which I don't want to use explode, implode to get the file1.zip file2.zip file3.zip


Normalize your data tables

items table

id  | item_name
--------------
1  | Item A
2  | Item B

item_files table

id  | item_id | item_files  
----------------------------------- 
1  | 1      | file1.zip
2  | 1      | file2.zip
3  | 1      | file3.zip 
4  | 2      | file3.zip 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜