I have the following code section that is used for displaying a list of items and would like to modify it so it displays as a multi column display.
I have been told that I need to use a counter, but I cannot find any information on how to do this. - Can anybody here help me with this, please, or point to an existing article with the relevant information in it?
// +--
// | Loop through the products.
// +--
foreach ($prodlist as $num => $prod) {
// +--
// | Print a table row opener.
// +--
print '<tr class="' . $trclass . '">' . $eol . $eol;
// +--
// | Print the tds and their content.
// +--
$prodname = $this->xhtml_encode($prod['name']);
$prodid = $this->xhtml_encode($prod['id']);
$prodlink = $this->link_namespace($app,'prodshow',$prod['id']);
$proddesc = $this->xhtml_encode($prod['descshort']);
$imgname = $prod['imgsm'];
$add_ok = 1;
if (($prod['useinv']) && (!($prod['invlevel'] > 0))) {$add_ok = 0;}
if ($prod['pricestatus'] == 'D') {$add_ok = 0;}
$quandisp = 0;
$quanform = $this->globals('khxc_cgi.' . $formid . '--' . $prodid . '--quantity');
if (isset($quanform)) {$quandisp = $quanform;}
if ($add_ok) {
print '<td class="' . $tdclass . '">' . $eol . $eol;
print '<label for="' . $formid . '--' . $prodid . '--quantity';
print '" class="hidden">Quantity</label>' . $eol;
print '<input class="khxc_formfield" type="text" name="';
print $formid . '--' . $prodid . '--quantity';
print '" id="' . $formid . '--' . $prodid . '--quantity';
print '" value="' . $quandisp . '" size="5" maxlength="5" />' . $eol;
print '</td>' . $eol . $eol;
} else {
print '<td class="' . $tdclass . '"> ' . $eol . $eol;
print '<label for="' . $formid . '--' . $prodid . '--quantity';
print '" class="hidden">Quantity</label>' . $eol;
print '<p class="hidden"><input type="hidden" name="';
print $formid . '--' . $prodid . '--quantity';
print '" id="' . $formid . '--' . $prodid . '--quantity';
print '" value="' . $quandisp . '" /></p>' . $eol;
print '</td>' . $eol . $eol;
} // End of if statement.
$image_ok = 0;
if ((!(empty($imgname))) && ($imgname != 'none.png')) {$image_ok = 1;}
if ($image_ok) {
$imgurl = 'media/' . $app . '/prodsm/' . $imgname;
$imgtag = '<a href="' . $prodlink . '" title="' . $prodname . '">';
$imgtag .= '<img src="' . $imgurl . '" ';
if ($imgwidth) {$imgtag .= 'width="' . $imgwidth . '" ';}
$imgtag .= 'alt="' . $prodname . '" /></a>';
print '<td class="' . $tdclass . '">' . $imgtag . '</td>' . $eol . $eol;
} else {
if ($multi_images) {
print '<td class="' . $tdclass . '"> </td>' . $eol . $eol;
} // End of if statement.
} // End of if statement.
print '<td class="' . $tdclass . '">';
print '<p><a href="' . $prodlink . '" title="' . $prodname . '">';
print $prodname . '</a></p>' . $eol;
if (!(empty($proddesc))) {print '<p>' . $proddesc . '</p>' . $eol;}
$this->globals('ecom.prod_proddisp',$prod);
$this->globals('ecom.prod_priceinfo',$prod['khxc.priceinfo']);
$this->include_file($app,'pricedisp.php');
if ($add_ok) {
$this->include_namespace($app,'prodshowoptlite',array('form' => $formid . '--' . $prodid, 'showquan' => 0, 'headfoot' => 0));
} // End of if statement.
print '</td>' . $eol . $eol;
// +--
// | Close the table row.
// +--
print '</tr>' . $eol . $eol;
} // End of foreach statement.