2
I have the following query:
$qrysel = "select * from pack";
$ressel = mysqli_query($db, $qrysel);
$obj = mysqli_fetch_object($ressel);
In html I have this:
<?= $obj['pack_name']; ?>
How could I make it show the value according to a certain id, without using the WHILE
and without putting the WHERE
in the query...
It is possible to define the WHERE
directly in html obj?
Table:
<table>
<tbody>
<tr>
<td>item 1</td>
<td>item 2</td>
<td>item 3</td>
</tr>
<tr><td> </td></tr>
<tr>
<td>item 4</td>
<td>item 5</td>
<td>item 6</td>
</tr>
</tbody>
</table>
If I were to use the while it would repeat all the TD then I need it to be displayed like this one above.
There are exactly 6 records in this table.
There’s no way. You’d have to use the
where
or in the worst case do a while and make the comparison record the record.– rray
Try to talk more about what you want to do, we can help with other ideas
– Victor Eyer
So, I can’t use the while because it goes from the problem with the display, as I have to display 3 items per row in a table.. with the while it will display all in a row.
– Wendler
It will be a problem because you probably have no experience working HTML+PHP, if you explain better what you have already done I’m sure you have how to solve.
– Guilherme Nascimento
I updated the question, take a look if you can understand what I need to do..
– Wendler
use a foreach($Ressel as $obj){if($obj['id']=1){echo"<td>$obj['name']</td>";}Else {echo "no record";} }
– Tulio Vieira
@Tulip tree I do not know how to assemble the structure using this method, if you can provide some example please..
– Wendler
@Eita this worked perfectly, I did not know this function. Thank you very much :D
– Wendler
@Wendler published a more detailed answer there that good that I helped you face I am very happy if you can vote in my publication and mark as answer is correct thank you!
– Tulio Vieira