Ver Mensaje Individual
  #27 (permalink)  
Antiguo 07/05/2011, 07:36
marina_mesas
 
Fecha de Ingreso: noviembre-2010
Mensajes: 48
Antigüedad: 13 años, 5 meses
Puntos: 5
Busqueda Respuesta: Como muestro una imagen

Buen dia Chicos;

A ver por ahi esto ayuda un poco mas! Tengo el buscador en la misma hoja php que el que muestra los productos al abrir la pagina por primera vez, o sea que al entrar en la pagina se ven el buscador arriba y abajo los productos.
Seria de esta manera:

Código PHP:
Ver original
  1. <?php
  2. if (!defined('WEB_ROOT')) {
  3.     exit;
  4. }
  5. ?>
  6. <form name="form0" method="post">
  7.  
  8.   <p>Busqueda rapida  
  9.     <input name="busca" type="text" />
  10.     <input type="submit" name="buscar" value="buscar" />
  11.   </p>
  12.   <p>&nbsp; </p>
  13. </form>
  14. <?php //Buscador
  15. if(isset($_POST['buscar']) && !empty($_POST['busca']))
  16. {
  17.     $busca=$_POST['busca'];
  18.  
  19.  
  20.         $busqueda = mysql_query("SELECT * FROM tbl_product WHERE pd_description LIKE '%".$busca."%'");
  21.         while($f = mysql_fetch_assoc($busqueda)){
  22.             $pd_thumbnail = $f['pd_thumbnail'];
  23.             if (!empty($pd_thumbnail) && $pd_thumbnail != "") {
  24.                 $pd_thumbnail = WEB_ROOT . 'images/product/' . $pd_thumbnail;
  25.             } else {
  26.                 $pd_thumbnail = WEB_ROOT . 'images/no-image-small.png';
  27.             }
  28.              echo "<img src='".$pd_thumbnail."'>&nbsp;&nbsp;".$f['pd_description']."&nbsp;&nbsp;".$f['pd_price']."<br>";  
  29.         }
  30.      
  31. }
  32. ?>
  33.  
  34. <?php // comienso del listado de productos sin el buscador
  35. if (!defined('WEB_ROOT')) {
  36.     exit;
  37. }
  38.  
  39. $productsPerRow = 1;
  40. $productsPerPage = 10;
  41.  
  42. $children = array_merge(array($catId), getChildCategories(NULL, $catId));
  43. $children = ' (' . implode(', ', $children) . ')';
  44.  
  45. $sql = "SELECT pd_id, pd_description, pd_thumbnail, pd_qty, c.cat_name, pd_price * sc_shipping_cost AS pd_price
  46.         FROM tbl_shop_config, tbl_product pd, tbl_category c
  47.         WHERE pd.cat_id = c.cat_id AND pd.cat_id IN $children
  48.         ORDER BY pd_description ASC";
  49. $result     = dbQuery(getPagingQuery($sql, $productsPerPage));
  50. $pagingLink = getPagingLink($sql, $productsPerPage, "c=$catId");
  51. $numProduct = dbNumRows($result);
  52.  
  53.  
  54. $columnWidth = (int)(100 / $productsPerRow);
  55. ?>
  56. <table width="100%" border="0" cellspacing="0" cellpadding="20">
  57. <?php
  58. if ($numProduct > 0 ) {
  59.  
  60.     $i = 0;
  61.     while ($row = dbFetchAssoc($result)) {
  62.    
  63.         extract($row);
  64.         if ($pd_thumbnail) {
  65.             $pd_thumbnail = WEB_ROOT . 'images/product/' . $pd_thumbnail;
  66.         } else {
  67.             $pd_thumbnail = WEB_ROOT . 'images/no-image-small.png';
  68.         }
  69.    
  70.         if ($i % $productsPerRow == 0) {
  71.             echo '<tr>';
  72.         }
  73.  
  74.        
  75.         $pd_price = displayAmount($pd_price);
  76.        
  77.         echo "<td width=\"$columnWidth=\" align=\"left\"><a><img src=\"$pd_thumbnail\" border=\"0\"></a></td>
  78.               <td width=\"$columnWidth%\" align=\"reight\"><a>Descripcion :  $pd_description</a><td><a> Precio : $pd_price</a>";
  79.              
  80.         if ($pd_qty <= 0) {
  81.             echo "<br> Agotado";
  82.         }
  83.        
  84.         echo "</td>\r\n";
  85.    
  86.         if ($i % $productsPerRow == $productsPerRow - 1) {
  87.             echo '</tr>';
  88.         }
  89.        
  90.         $i += 1;
  91.     }
  92.    
  93.     if ($i % $productsPerRow > 0) {
  94.         echo '<td colspan="' . ($productsPerRow - ($i % $productsPerRow)) . '">&nbsp;</td>';
  95.     }
  96.    
  97. } else {
  98. ?>
  99.     <tr><td width="100%" align="center" valign="center">No hay productos en esta categoria</td></tr>
  100. <?php  
  101. }
  102.    
  103. ?>
  104. </table>
  105. <p align="center"><?php echo $pagingLink; ?></p>
  106. <p align="center">&nbsp;</p>

Talvez esto de un panorama mas calro del asunto!!

Un