I have a column in my table, with titled: sum_days
id | Name | Sum_Days |
---+------+----------+
1 | Ed | 3 |
2 | Jane | 4 |
3 | Rose | 2 |
I need to show sum_days onto the page with buttons, for example I want to show Ed's Sum of Days, 3 days so on the page will show three buttons based on the number in the table column.
I'm using Laravel code like this:
return <a href="employees/'.$st->id.'" class="btn btn-warning btn-sm">Day-'.$st->sum_days.'</a>';
But it's showing the whole data, not each button from the sum of the days. It should be
> [ButtonDay-1] [ButtonDay-2] [ButtonDay-3]
I was confused how to do it, any suggestion or help I would be thankful. Thank you.
Simply put it inside a loop should do it :
$links = '';
for ($i = 1; $i <= $st->sum_days; $i++) {
$links .= '<a href="employees/' . $st->id . '" class="btn btn-warning btn-sm">Day-' . $i . '</a>';
}
return $links;