listaprod.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. include('db.php');
  3. $statement = $db->prepare("SELECT p.nombre, d.desc_corta, d.descripcion
  4. FROM productos p
  5. left join descripcion d on p.idproducto = d.idproducto
  6. left join categorias c on c.idcategoria = p.categoria
  7. WHERE c.nombre = ? AND c.idioma = 'espanol' ");
  8. $cat = 'Limpieza';
  9. if (isset($_GET['cat'])) {
  10. $cat = $_GET['cat'];
  11. }
  12. $statement->bind_param('s', $cat);
  13. $statement->execute();
  14. $statement->store_result();
  15. $statement->bind_result($nombre,$desc,$descripcion);
  16. $count=$statement->num_rows;
  17. /* var productos = [] ;
  18. $.each(prod, function(i, item) {
  19. var proddiv = $('<div/>', {
  20. class: 'producto',
  21. html: item['html']
  22. });
  23. var img = "Images/producto.jpg";
  24. productos.push(proddiv);
  25. });
  26. var lista_prod = $('<div/>', {
  27. id: 'lista_productos',
  28. html: productos
  29. });
  30. var pagina = $('<div/>', {
  31. id: 0, //incrementar
  32. class: 'pagina',
  33. html: lista_prod
  34. });
  35. */
  36. $i=0;
  37. $pag=0;
  38. while ( $statement->fetch() ) {
  39. if (($i-1) % 6 && $i > 2 || $i == 0) {
  40. echo "<div class='pagina' id='pagina-$pag'>\n";
  41. $pag++;
  42. }
  43. if(($i-1) % 2 && $i > 2 || $i == 0){
  44. echo "<div class='listaproductos'>\n";
  45. }
  46. $html ="<div class='imagen'>
  47. <img src='Images/producto.jpg'>
  48. </div>
  49. <div class='texto'>
  50. <h5>$nombre</h5><br>$desc<br><br><u>Ver más</u>
  51. </div>";
  52. echo $html;
  53. if($i % 2)
  54. {
  55. echo "</div>";
  56. }
  57. if ($i % 6) {
  58. echo "</div>"; //pagina
  59. //echo "</div>"; //listaprod
  60. }
  61. $i++;
  62. }
  63. ?>