My url does not get the id parameter in the show? id =. Because?

0

Question: My url does not get the id parameter in mostra?id=.

Code:

<table class="table table-striped table-bordered table-hover">
<?php foreach($produtos as $p): ?>
  <tr>
    <td><?= $p->nome ?></td>
    <td><?= $p->valor ?></td>
    <td><?= $p->descricao ?></td>
    <td><?= $p->quantidade ?></td>
    <td><a href="https://localhost/estoque/public/produtos/mostra?id=<?php 
        $p->id ?>"><span class="glyphicon glyphicon-search"></span></a></td>
  </tr>
<?php endforeach ?>

    
asked by anonymous 09.08.2018 / 14:49

1 answer

1

In the part where you set link :

<a href="https://localhost/estoque/public/produtos/mostra?id=<?php 
        $p->id ?>"><span class="glyphicon glyphicon-search"></span></a>

You are not "typing" the value of id . So, for the value to appear you have to make a echo :

<?php echo $p->id; ?>

Or you can use the short form:

<?= $p->id ?>
    
09.08.2018 / 15:08