I have a database where in the users table I have the columns:
+----------+------------+----------+------------+----------+------------+
| imp_cod1 | imp_local1 | imp_cod2 | imp_local2 | imp_cod3 | imp_local3 |
+----------+------------+----------+------------+----------+------------+
| 13 | RECEPÇÃO | | | 18 | CEO |
+----------+------------+----------+------------+----------+------------+
Note that the values of imp2
are all empty, because in this case only imp1
is with data.
In my html code I use the following format to display the imp1 information:
<div class="panel-body">
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>Impressora</th>
<th>Modelo</th>
<th>Contagem</th>
<th>Situação</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><?php echo $imp_cod1; ?></th>
<td><b><?php echo $imp_local1; ?></b></td>
<td><?php echo $imp_modelo1; ?></td>
<td><?php echo $imp_contador1; ?></td>
<td><button type="button" class="btn btn-round btn-success"><?php echo $imp_situacao1; ?></button></td>
</tr>
</tbody>
</table>
</div>
Now when I have a second given in imp2
, imp3
... I go manually and create a new result field as the above example quoted <tr>
I would like to know if there is any way I can make it automatic so that I do not have to edit PHP every time I insert or delete new data in the table.
Connection code with db (every page that requires the user to be logged in has an include for this page): link
p>Code from my page where I'm having trouble automatically adding new rows: link (on line 251 has the first fill of data , it ends at 257. Below is another 7 fills where I already left it ready.)
Now suppose that the user only has imp1
and all others are empty, even so my system will look for all other ones and leave it blank, and because the html code is already created, it leaves the lines created but in white too. I would like to know if I can make it become automatic in theory: if the imp field is empty do not create line, otherwise create line and fill data ...
If I'm going the wrong way in logic I'm able to change, I'm a beginner and I was urgently at the end of it.
Here is a photo of how the system is left with blank data: