if then php syntax help needed

I need help with:
[php]<?php
$sql=“SELECT * FROM tks ORDER BY id ASC”;
$prod=select($sql);
for($i=0;$i<count($prod)-1;$i++){
If $prod[$i][‘category’] == ‘Appetizers’
{?>


<?= $prod[$i]['category']; ?>

<?= $prod[$i]['reference']; ?>

<?= $prod[$i]['nombre']; ?>

<?= $prod[$i]['description']; ?>

<?= $prod[$i]['price']; ?>

<?= $prod[$i]['img']; ?>

Edit

Delete

	<?php
}}

?>[/php]
I want to display on page each line has Appetizers in it but not if it does not.
Thanks,
Ray

why not just select the rows required using sql rather than filtering the results?
[php]$sql=“SELECT * FROM tks WHERE category=‘Appetizers’ ORDER BY id ASC”;[/php]

Red :wink:

I figured it out:
[php] $sql=“SELECT * FROM tks ORDER BY id ASC”;
$prod=select($sql);
for($i=0;$i<count($prod)-1;$i++)
{
$abid= $prod[$i][‘id’];
$abcat= $prod[$i][‘category’];
$abre = $prod[$i][‘reference’];
$abno = $prod[$i][‘nombre’];
$abde = $prod[$i][‘description’];
$abpr = $prod[$i][‘price’];
$abim = $prod[$i][‘img’];
$abline = $abre . ’ ’ . $abno;
if (strlen($abre) > 4)
{$addpt=42;}
else
{$addpt=37;}
if (strlen($abpr) == 5){–$addpt;}
$absline = str_pad($abline, $addpt , “.”,STR_PAD_RIGHT);
$abxline = $absline . $abpr;
if ($abcat == Salads)
{
[/php]
Been writing assembly code for decades but had to learn php syntax as I go along.
Now is I can get my subroutines (functions) working :slight_smile:
Thanks,
Ray

Sponsor our Newsletter | Privacy Policy | Terms of Service