Ver Mensaje Individual
  #30 (permalink)  
Antiguo 09/05/2011, 10:45
marina_mesas
 
Fecha de Ingreso: noviembre-2010
Mensajes: 48
Antigüedad: 13 años, 5 meses
Puntos: 5
De acuerdo Respuesta: Como muestro una imagen

Cita:
Iniciado por angelfcm Ver Mensaje
Hola!
Viendo la cantidad de código, es mucho más eficiente que nos dejaras todo el código fuente para realizar todo ese proceso e incluso el script para crear las tablas de mysql, y así te aseguro que obtendrás resultados muy muy rápidos ya que así podemos hacer una simulación igual a la tuya.
Saludos!
Hola Angelfcm !

A ver si te ayuda!

Tabla SQL
Código MySQL:
Ver original
  1. DROP TABLE IF EXISTS `tbl_product`;
  2. CREATE TABLE `tbl_product` (
  3.   `cat_id` int(10) unsigned NOT NULL default '0',
  4.   `pd_name` varchar(100) NOT NULL default '',
  5.   `pd_description` text NOT NULL,
  6.   `pd_price` decimal(9,2) NOT NULL default '0.00',
  7.   `pd_qty` smallint(5) unsigned NOT NULL default '0',
  8.   `pd_image` varchar(200) default NULL,
  9.   `pd_thumbnail` varchar(200) default NULL,
  10.   `pd_date` datetime NOT NULL default '0000-00-00 00:00:00',
  11.   `pd_last_update` datetime NOT NULL default '0000-00-00 00:00:00',
  12.   PRIMARY KEY  (`pd_id`),
  13.   KEY `cat_id` (`cat_id`),
  14.   KEY `pd_name` (`pd_name`)
  15. ) TYPE=MyISAM AUTO_INCREMENT=22 ;

Esto seria el index.php

Código PHP:
Ver original
  1. <?php
  2. require_once 'library/config.php';
  3. require_once 'library/category-functions.php';
  4. require_once 'library/product-functions.php';
  5. require_once 'library/cart-functions.php';
  6.  
  7. $_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];
  8.  
  9. $catId  = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
  10. $pdId   = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;
  11.  
  12. require_once 'include/header.php';
  13. ?>
  14. <table width="1022" height="587" border="0" align="center" cellpadding="0" cellspacing="0">
  15.  <tr>
  16.   <td colspan="5"><?php require_once 'include/top.php'; ?></td>
  17.  </tr>
  18.  <tr valign="top">
  19.  <td width="53"></td>
  20.   <td width="109" height="400" bgcolor="#424242" id="leftnav" border="0"><?php
  21. require_once 'include/leftNav.php';
  22. ?></td>
  23. <td width="11"></td>
  24.   <td width="773" align="center" bgcolor="#FFFFFF" id="cat"><p>
  25.  
  26.   </p>
  27.     <p>
  28.       </p>
  29.       <?php
  30.     require_once 'include/productList.php';
  31. ?>
  32.  
  33.   <td width="74"></td>
  34.  
  35. <td width="2"></td>
  36.  
  37. </table>
  38. <?php
  39. require_once 'include/footer.php';
  40. ?>

y aca el achivo en cuestion porductList.php

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>

y aca config.php

Código PHP:
Ver original
  1. <?php
  2. ini_set('display_errors', 'On');
  3.  
  4.  
  5.  
  6. $dbHost = 'localhost';
  7. $dbUser = 'xx';
  8. $dbPass = 'xx';
  9. $dbName = 'xx';
  10.  
  11. $thisFile = str_replace('\\', '/', __FILE__);
  12. $docRoot = $_SERVER['DOCUMENT_ROOT'];
  13.  
  14. $webRoot  = str_replace(array($docRoot, 'library/config.php'), '', $thisFile);
  15. $srvRoot  = str_replace('library/config.php', '', $thisFile);
  16.  
  17. define('WEB_ROOT', $webRoot);
  18. define('SRV_ROOT', $srvRoot);
  19.  
  20. define('CATEGORY_IMAGE_DIR', 'images/category/');
  21. define('PRODUCT_IMAGE_DIR',  'images/product/');
  22.  
  23. define('MAX_CATEGORY_IMAGE_WIDTH', 85);
  24.  
  25. define('LIMIT_PRODUCT_WIDTH',     true);
  26.  
  27. define('MAX_PRODUCT_IMAGE_WIDTH', 350);
  28.  
  29. define('THUMBNAIL_WIDTH',         85);
  30.  
  31.     if (isset($_POST)) {
  32.         foreach ($_POST as $key => $value) {
  33.             $_POST[$key] =  trim(addslashes($value));
  34.         }
  35.     }
  36.    
  37.     if (isset($_GET)) {
  38.         foreach ($_GET as $key => $value) {
  39.             $_GET[$key] = trim(addslashes($value));
  40.         }
  41.     }  
  42. }
  43.  
  44. require_once 'database.php';
  45. require_once 'common.php';
  46.  
  47.  
  48. $shopConfig = getShopConfig();
  49. ?>

Calculo que es lo mas necesario!! Espero que te sirva!! Un y de ante mano mil gracias !!