[英]How to display results of same column but have different values
Here I'm returning data from my database which have a title_heading column and it has a title column.在这里,我从我的数据库中返回数据,其中有一个 title_heading 列和一个 title 列。
id title_heading title
1 HTML Tutorial Home
2 HTML Tutorial Overview
3 HTML References Tags
4 HTML References Events
but now I wanted to show the results like this in my view:但现在我想在我看来显示这样的结果:
**HTML Tutorial**
Home
Overview
**HTML References**
Tags
Events
i have two idea on this.. first normalize that table into two table..我对此有两个想法..首先将该表规范化为两个表..
heading : [id,name] subTitle : [id, name, heading_id]标题:[id,名称] 子标题:[id,名称,heading_id]
then you make oneToMany Relationship in laravel然后你在 Laravel 中建立 oneToMany 关系
https://laravel.com/docs/5.7/eloquent-relationships#one-to-many https://laravel.com/docs/5.7/eloquent-relationships#one-to-many
second you can use nested loop it and push it into array..第二,您可以使用嵌套循环并将其推入数组..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.