Antes de que me pidiera el buscador
Aqui les dejo el php de la pagina product.php que es cargada por un index que carga todos los componentes:
Código PHP :
[size=8]<form name="form1" method="post" action="./index.php">
<p>Busqueda rapida
<input name="busca" type="text" id="busca" />
<input type="submit" name="Submit" value="buscar" />
</p>
<p> </p>
</form>
<?php // buscador mas listado de aperiencia de productos buscados
$productsPerRow = 1;
$productsPerPage = 10;
$children = array_merge(array($catId), getChildCategories(NULL, $catId));
$children = ' (' . implode(', ', $children) . ')';
$busca="";
$busca=$_POST['busca'];
if($busca!=""){
$busqueda=mysql_query("SELECT pd_id, pd_description, pd_thumbnail, pd_qty, c.cat_name, pd_price * sc_shipping_cost AS pd_price
FROM tbl_shop_config, tbl_product pd, tbl_category c
WHERE pd_description
LIKE '%".$busca."%'");
$columnWidth = (int)(100 / $productsPerRow);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="20">
<?php
while($pd=@mysql_fetch_array($busqueda)){
extract($row);
if ($pd_thumbnail) {
$pd_thumbnail = WEB_ROOT . 'images/product/' . $pd_thumbnail;
} else {
$pd_thumbnail = WEB_ROOT . 'images/no-image-small.png';
}
echo "<td width=\"$columnWidth=\" align=\"left\"><a><img src=\"$pd_thumbnail\" border=\"0\"></a></td>
<td width=\"$columnWidth%\" align=\"reight\"><a>Descripcion : $pd_description</a><td><a> Precio : $pd_price</a>";
echo "</td>\r\n";
if ($i % $productsPerRow == $productsPerRow - 1) {
echo '</tr>';
}
$i += 1;
}
if ($i % $productsPerRow > 0) {
echo '<td colspan="' . ($productsPerRow - ($i % $productsPerRow)) . '"> </td>';
}
}
?>
</table>
<?php // comienso del listado de producto sin accionar el buscador
if (!defined('WEB_ROOT')) {
exit;
}
$productsPerRow = 1;
$productsPerPage = 10;
$children = array_merge(array($catId), getChildCategories(NULL, $catId));
$children = ' (' . implode(', ', $children) . ')';
$sql = "SELECT pd_id, pd_description, pd_thumbnail, pd_qty, c.cat_name, pd_price * sc_shipping_cost AS pd_price
FROM tbl_shop_config, tbl_product pd, tbl_category c
WHERE pd.cat_id = c.cat_id AND pd.cat_id IN $children
ORDER BY pd_description ASC";
$result = dbQuery(getPagingQuery($sql, $productsPerPage));
$pagingLink = getPagingLink($sql, $productsPerPage, "c=$catId");
$numProduct = dbNumRows($result);
$columnWidth = (int)(100 / $productsPerRow);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="20">
<?php
if ($numProduct > 0 ) {
$i = 0;
while ($row = dbFetchAssoc($result)) {
extract($row);
if ($pd_thumbnail) {
$pd_thumbnail = WEB_ROOT . 'images/product/' . $pd_thumbnail;
} else {
$pd_thumbnail = WEB_ROOT . 'images/no-image-small.png';
}
if ($i % $productsPerRow == 0) {
echo '<tr>';
}
$pd_price = displayAmount($pd_price);
echo "<td width=\"$columnWidth=\" align=\"left\"><a><img src=\"$pd_thumbnail\" border=\"0\"></a></td>
<td width=\"$columnWidth%\" align=\"reight\"><a>Descripcion : $pd_description</a><td><a> Precio : $pd_price</a>";
if ($pd_qty <= 0) {
echo "<br> Agotado";
}
echo "</td>\r\n";
if ($i % $productsPerRow == $productsPerRow - 1) {
echo '</tr>';
}
$i += 1;
}
if ($i % $productsPerRow > 0) {
echo '<td colspan="' . ($productsPerRow - ($i % $productsPerRow)) . '"> </td>';
}
} else {
?>
<tr><td width="100%" align="center" valign="center">No hay productos en esta categoria</td></tr>
<?php
}
?>
</table>
<p align="center"><?php echo $pagingLink; ?></p>
<p align="center"> </p>[/size]Desde ya muchas gracias y porfi traten de ser claros que mi php no es muy bueno y esto me llevo mucho tiempo de desmenusar, entender y armar!
Besitos
