Nieuw lid |
|
Hallo,
Ben bezig een catalogus samenstellen vanuit virtuemart. De gegevens zijn ingevoerd in VM en deze wil ik gebruiken om een catalogus samen te stellen. De code die ik nu heb is als volgt:
<?php
require_once 'db_config.php';
$get_product_fields = "SELECT product_sku, product_name, category_name
FROM meta_vm_product, meta_vm_product_category_xref, meta_vm_category
WHERE meta_vm_product.product_id=meta_vm_product_category_xref.product_id
AND meta_vm_category.category_id=meta_vm_product_category_xref.category_id
ORDER BY category_name";
$result_product=mysql_query($get_product_fields);
$num=mysql_numrows($result_product);
mysql_close();
?>
<?php $i=0; while ($i < $num), {
$f1=mysql_result($result_product,$i,"category_name");
$f2=mysql_result($result_product,$i,"product_name");
$f3=mysql_result($result_product,$i,"product_sku");
?>
<table border="0" align="center" cellspacing="0" cellpadding="2">
<tr>
<th colspan=6 width="220" bgcolor="#3d756c">
<div align="left"><font color="#C4C067" face="Arial, Helvetica, sans-serif" size="5"><span>
<?php echo $f1; ?>
</span></font></div>
</th>
</tr>
<td colspan=2 bgcolor="#FFFDCA" bordercolor="#003333"> <font face="Arial, Helvetica, sans-serif" size="3"><span>
<?php echo $f2; ?>
</span></font></td>
<td width="150" bgcolor="#FFFFFF">
<div align="left"><font face="Arial, Helvetica, sans-serif" size="3"><span class="style30" >
<?php echo $f3; ?>
</span></font></div>
</td>
</table>
<?php
$i++;
}
?>
<?php require_once 'db_config.php'; $get_product_fields = "SELECT product_sku, product_name, category_name FROM meta_vm_product, meta_vm_product_category_xref, meta_vm_category WHERE meta_vm_product.product_id=meta_vm_product_category_xref.product_id AND meta_vm_category.category_id=meta_vm_product_category_xref.category_id ORDER BY category_name"; ?> <?php $i=0; while ($i < $num), { ?> <table border="0" align="center" cellspacing="0" cellpadding="2"> <tr> <th colspan=6 width="220" bgcolor="#3d756c"> <div align="left"><font color="#C4C067" face="Arial, Helvetica, sans-serif" size="5"><span> </span></font></div> </th> </tr> <td colspan=2 bgcolor="#FFFDCA" bordercolor="#003333"> <font face="Arial, Helvetica, sans-serif" size="3"><span> </span></font></td> <td width="150" bgcolor="#FFFFFF"> <div align="left"><font face="Arial, Helvetica, sans-serif" size="3"><span class="style30" > </span></font></div> </td> </table> <?php $i++; } ?>
Dit werkt echter ik krijg boven elke rij met gegevens (product_sku en prduct_name) elke keer de category naam te staan.
Ik wil dat één maal de categorynaam wordt getoont met daaronder de rijen met genoemde gegevens.
Heeft iemand de oplossing.
Henk
|