F
F
FastClick2019-08-25 11:46:59
HTML
FastClick, 2019-08-25 11:46:59

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"}]

5d624ad4187c3124419916.jpeg
Consider the table:
Number = id
Test = test_1
Test = test_2

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
Hey One, 2019-08-25
@twofolls95

On php. With a foreach loop. Well and still the request is necessary in a DB.

A
Anton R., 2019-08-25
@anton_reut

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 question

Ask a Question

731 491 924 answers to any question