I want to make static data row in table for 10 rows. I have 3 data foreach (item01, item02, item03) like this.
<table>
<?php foreach($data as $row): ?>
<tr>
<td><?php echo $row->item_no; ?></td>
</tr>
<?php endforeach;
</table>
I want to make in my table like this :
No | Item No |
---|---|
1 | Item01 |
2 | Item02 |
3 | Item03 |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 |
How I can do that in my php code ?
4
Answers
first get the size of your data:
then you could simply use a for loop:
which outputs:
Use forloop to loop 10 row for the table.
This code meaning if $data is not empty then show $data->item_no else show empty.
Try this
Try This: