I'm trying to display a list of subscriptions for a particular user. The getuser()
method captures the id of the session user and displays the list of entries created by it.
However, I'm trying to display these records on screen, while I did not use WHERE
with id displayed correctly, all the database data. But after some changes, the following message is displayed on screen:
Notice: Trying to get property of non-object in C: \ xampp \ htdocs \ vakkinha \ index.php on line 128 No Kitty Created
See the code below:
<?php
$vakkinha2->setuser($idresp);
$teste=$vakkinha2->getuser();
$r = $vakkinha2->buscarIDUser();
print_r($r);
if($r->num_rows > 0){
$found = $r->fetch_assoc();
?>
<section class="table container"><b>
<meta charset="utf-8"><h3 font face="Arial">Vakkinhas no Sistema</h3><b>
<table class="table table-hover">
<tr class="warning">
<th>id</th>
<th>titulo</th>
<th>finalidade</th>
<th>meta</th>
<th>encerra_em</th>
<th>descricao</th>
<th>linkimg</th>
<th>linkvideo</th>
<th>nº do usuário</th>
<th>Alterar</th>
<th>Excluir </th>
</tr>
<?php
while($linha = $result->fetch_assoc()){
$found[] = $linhas;
print "<tr>";
print "<td>".$linha['idvakkinha']."</td>";
print "<td>".$linha['titulo']."</td>";
print "<td>".$linha['finalidade']."</td>";
print "<td>".$linha['meta']."</td>";
print "<td>".$linha['encerra_em']."</td>";
print "<td>".$linha['descricao']."</td>";
print "<td>".$linha['linkimg']."</td>";
print "<td>".$linha['linkvideo']."</td>";
print "<td>".$linha['iduser']."</td>";
print "<td><a href='altervakkinha.php?idvakkinha=".$linha['idvakkinha']."'>Alterar</a><td>";
print "<td><a href='apgvakkinha.php?idvakkinha=".$linha['idvakkinha']."'>Excluir</a><td>";
print "</tr>";
}
print "</table>";
}else{
echo "Nenhuma Vaquinha Criada";
}
?>
Above, I started the $r
on screen to see if it was capturing the data and yes, it returns the records of that particular user:
Array ([idvakkinha] => 2 [0] => 2 [title] => vakkinha [1] = > vakkinha [purpose] = > success [2] = > success [meta] = > success [3] = > success [closes_em] = > 2020-02-02 [4] = > 2020-02-02 [description] = > success [5] = > success [linkimg] = > success [6] = > success [linkvideo] = > success [7] = > success [iduser] = > 1 [8] = > 1)