3条回答 默认 最新
- dsyo9700 2019-02-13 10:48关注
I had same isssue while making API for PHP.
Try this , declare your Item name , quanity and date as TEXT and insert nested JSON in those fields.
i.e.
//while adding to DB json will look like "[{ABC},{PQR},{XYZ}]","[{23},{56},{14}]","[{23/05/1900 12:00 GMT},{23/05/1908 12:00 GMT},{23/05/1980 12:00 GMT}]"
So,
"[{ABC},{PQR},{XYZ}]"
go to item_name column,"[{23},{56},{14}]"
goes to quantity column,"[{23/05/1900 12:00 GMT},{23/05/1908 12:00 GMT},{23/05/1980 12:00 GMT}]"
goes to date columnas simple string or text. Here's below is my HTML Code for Table (Ignore style ☺)
<table> <thead> <tr> <td>ITEM_NAME</td> <td>QUANTITY</td> <td>DATE</td> </tr> </thead> <tbody> <tr> <td>ABC</td> <td>23</td> <td>23/05/1900 12:00 GMT</td> </tr> <tr> <td>PQR</td> <td>56</td> <td>23/05/1908 12:00 GMT</td> </tr> <tr> <td>XYZ</td> <td>14</td> <td>23/05/1980 12:00 GMT</td> </tr> </tbody>
So while adding to Database you need first push data to object then Stringyfy it and then send to database. And while fetching from database and displaying again to UI , you need to Parse those strings back to Objects then you can apply looping like it is an Nested object.
Happy Codeing ☻
</div>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 1