Answer the question
In order to leave comments, you need to log in
How to enter data from a database into a table?
I get this information from the user base. How can I display these values in a table, so to speak. An example is below.
[{"id":"5","test_1":"test.5","test_2":"testing.5"},{"id":"4","test_1":"test.4","test_2":"testing.4"},{"id":"1","test_1":"test.1","test_2":"testing.1"}]
Answer the question
In order to leave comments, you need to log in
On php. With a foreach loop. Well and still the request is necessary in a DB.
For example like this:
<table>
<?php foreach ($items as $item):?>
<tr>
<td>
<?php echo date("d.m.Y", strtotime($item['date']));?>
</td>
<td>
<a href="/item/item.php?item_id=<?php echo $item['id']?>">
<img src="/images/<?php echo$item['image'];?>" class="small-image">
</a>
</td>
<td>
<a href="/item/item.php?item_id=<?php echo $item['id']?>">
<?php echo mb_strimwidth($item['name'], 0, 30, "...");?>
</a>
</td>
<td>
<?php echo number_format($item['price'],0,"."," ");?> руб.
</td>
<td>
<?php echo $item['categoryname'];?>
</td>
<td>
<img src="../images/eye.png" title="Просмотров объявления"> <?php echo $item['views'];?>
</td>
</tr>
<?php endforeach;?>
</table>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question