lucas
14 janv. 2009 à 18:30
bonjour je souhaite profiter de ton experience en php pour resoudre ce perti souci avec while if echo
cars je comprends pas grande chose en php merci d'avance lucas
ps. desolee pour le francais je suis bresilien
voila c'est un boite qu'affiche la categorie parent en têtê et les sous-categories en bas avec une image plus le prix e le mon de produit
j'arrive juste a affiche la categorie parent et les sous categories)
voici mon code
<?php
$query = ("select c.categories_id, cd.categories_name, c.parent_id, c.categories_image from " .
TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id
order by sort_order, cd.categories_name limit 30");
$categories_query = tep_db_query($query);
while ($categories = tep_db_fetch_array($categories_query)){
if ($categories['categories_id'] == 22) {
$cPath_new = tep_get_path($categories['categories_id']);
text_subcategories = '';
$subcategories_query = tep_db_query($query);
while ($subcategories = tep_db_fetch_array($subcategories_query)) {
if ($subcategories['parent_id'] == $categories['categories_id'])
{
$cPath_new_sub = "cPath=" . $categories['categories_id'] . "_" . $subcategories['categories_id'];
$text_subcategories .= ' <font color="#fe9900"> • </font> <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">' . $subcategories['categories_name'] . '</a>
<hr color="#CCCCCC" align=left width="175" size="1">' . " ";
}
}
echo '
<table cellspacing=0 cellpadding=0 bgcolor="#FFFFFF">
<tr><td height=8></td></tr>
<tr><td background=images/header/menu.gif width=390 height=30>
<table cellspacing=0 cellpadding=0 align=left>
<a class="main12" href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '"> <b>' . $categories['categories_name'] . '</b></a>
</td></tr>
</table>
</td></tr>
<tr><td class=bg5a align=center>
<table background=images/header/bas_box_cat.gif cellspacing=0 cellpadding=0 align=left width=390 border=2>
<tr><td bgcolor=#ffffff height=0 colspan=2></td></tr>
<tr><td align=left class="smallText" width="280" valign="top" height=175>' . $text_subcategories . '<font color=fe9900> » </font><a class=main13 href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">voir la liste complête</a>';
$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_quantity, p.products_tax_class_id, p.products_price, manufacturers_id, p2c.categories_id, p2c.products_id from " . TABLE_PRODUCTS . " p, products_description pd, products_to_categories p2c where p2c.products_id = pd.products_id AND p.products_id = pd.products_id and p.products_status = '1' and (p2c.categories_id = 103 or p2c.categories_id = 49 or p2c.categories_id = 50 or p2c.categories_id = 85 or p2c.categories_id = 51 or p2c.categories_id = 102 or p2c.categories_id = 104) order by rand() desc limit 1");
while ($new_products = tep_db_fetch_array($new_products_query)) {
$new_products['products_name'] = tep_get_products_name($new_products['products_id']);
$manufacturer_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = ". $new_products['manufacturers_id']);
$manufacturer = tep_db_fetch_array($manufacturer_query);
$product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$new_products['products_id'] . "' and language_id = '" . (int)1 . "'");
$product = tep_db_fetch_array($product_query);
$new_products['products_description'] = $product['products_description'];
// if (MODULE_ORDER_TOTAL_ECOTAX_STATUS=='true' && !$new_products['ecotax_rates_id']=="0"){
// $new_products_ecotax=tep_get_ecotax_description($new_products['ecotax_rates_id']);
// $ecotax_rates_id=($new_products['ecotax_rates_id']!=$new_products_ecotax[0]['ecotax_id_other']&&$new_products_ecotax[0]['ecotax_id_other']!="" && $new_products_ecotax[0]['ecotax_id_other']!="0")?$new_products_ecotax[0]['ecotax_id_other']:$new_products['ecotax_rates_id'];}
//fin modif by paddybl for ecotax</P> <P> tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");</P> <P> if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
//debut modif by paddybl for ecotax
$products_price = '<s style="color:#777777; font-size:12px">' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']),$ecotax_rates_id) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($new_products['products_tax_class_id']),$ecotax_rates_id) . '</span>';
{
$products_price = $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']),$ecotax_rates_id);
}
echo '
</td><td width=176 valign=top align=center>
<table cellspacing=0 cellpadding=0 align=center width=300 border=3>
<tr><td height=35 valign=top colspan=2> <a class=tx13 href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">'. $manufacturer['manufacturers_name'] . ' ' . $new_products['products_name'] . '</a>
</td></tr>
<tr><td colspan=2><img src=images/header/m42.gif width=170 height=1></td></tr>
<tr><td height=3 colspan=2></td></tr>
<tr><td valign=top align=center colspan=2>
<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, ' class=br') . '</a>' . $new_products['products_name2'] . '</td>
</tr>
<tr><td height=3 colspan=2></td></tr>
<tr><td align=center width=176 class=tx6>'.$products_price.'<img src=images/header/01.gif width=77 height=16></td></tr>
</table>
</td>
'; }echo '</tr>
</table>
</td></tr>
<tr><td align=center width=176 class=tx6>'.$products_price.'</td><td>
</table>';
}
}
?>