Ver Mensaje Individual
  #4 (permalink)  
Antiguo 16/01/2009, 22:34
armax
 
Fecha de Ingreso: enero-2009
Mensajes: 3
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Mostrar productos por consulta

Cita:
Ok aprendi a enviar archivos, ahora te muestro lo que hice y cual es mi dilema... la pagina de donde veo los productos se llama listaproductos.php y es esta..

Código PHP:
<?php require_once('Connections/cn.php'); ?>
<?php
session_start
();
if (!
function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$colname_rsproductos "-1";
if (isset(
$_GET['CodigoCategoria'])) {
  
$colname_rsproductos $_GET['CodigoCategoria'];
}
mysql_select_db($database_cn$cn);
$query_rsproductos sprintf("SELECT IdProducto, NombreProducto, CantidadPorUnidad, PrecioUnidad, imagenchica FROM productos WHERE IdCategoria = %s"GetSQLValueString($colname_rsproductos"int"));
$rsproductos mysql_query($query_rsproductos$cn) or die(mysql_error());
$row_rsproductos mysql_fetch_assoc($rsproductos);
$totalRows_rsproductos mysql_num_rows($rsproductos);

mysql_select_db($database_cn$cn);
$query_rsOferta "SELECT IdProducto, NombreProducto, CantidadPorUnidad, PrecioUnidad, imagenchica FROM productos WHERE enoferta = 1";
$rsOferta mysql_query($query_rsOferta$cn) or die(mysql_error());
$row_rsOferta mysql_fetch_assoc($rsOferta);
$totalRows_rsOferta mysql_num_rows($rsOferta);

$columnas=4;
$contador=0;

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/plantillabase.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>... Productos Digitales ...</title>
<!-- InstanceEndEditable -->
<?php
$total
=0;
if (isset(
$_SESSION['carrito'])){
    
$carrito=$_SESSION['carrito'];
    
$total=0;
    foreach(
$carrito as $k => $v){
        
$subtotal=$v['cantidad']*$v['precio'];
        
$total+=$subtotal;
    }
}
mysql_select_db($database_cn$cn);
$query_rsCategorias "SELECT * FROM categorias";
$rsCategorias mysql_query($query_rsCategorias$cn) or die(mysql_error());
$row_rsCategorias mysql_fetch_assoc($rsCategorias);
$totalRows_rsCategorias mysql_num_rows($rsCategorias);

mysql_select_db($database_cn$cn);
$query_rsMarcas "SELECT * FROM marcas";
$rsMarcas mysql_query($query_rsMarcas$cn) or die(mysql_error());
$row_rsMarcas mysql_fetch_assoc($rsMarcas);
$totalRows_rsMarcas mysql_num_rows($rsMarcas);


?>
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="estilogeneral.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div class="fondo">
<div class="menuencabezado">
  <div class="mensajetitulo">
  <?php
  
if(isset($_SESSION['MM_Nombres'])){
  echo 
"<a href='cerrarsesion.php'>Cerrar sesiòn</a> - Usuario: ".$_SESSION['MM_Nombres'];
  } 
?>  
  
  Total: S/.<?php echo number_format($total,2?> </div>
  <a href="index.php">Inicio</a> | <a href="listaproductos.php">Productos</a> | <a href="carritodecompras.php">Carrito de compras</a> | <a href="#">Clientes</a></div>
<div>
<div class="zonaizquierda">
<div class="zonalogo">zona logo</div>
<div>

 
  <p>&nbsp;</p>
  
    <ul id="MenuBar1" class="MenuBarVertical">
    
    <?php do { ?>
     <li><a href="listaproductos.php?CodigoCategoria=<?php echo $row_rsCategorias['IdCategoria']; ?>" title="<?php echo $row_rsCategorias['Descripcion']; ?>"><?php echo $row_rsCategorias['NombreCategoria']; ?></a></li>
      <?php } while ($row_rsCategorias mysql_fetch_assoc($rsCategorias)); ?>
   </ul>
  <p>menu vertical</p>
</div>
zona izquierda</div>
<div class="zonaderecha">
<div><!-- InstanceBeginEditable name="zonaimagen" --><img src="imagenes/imagenproductos.jpg" alt="" width="600" height="200" /><!-- InstanceEndEditable --></div>
<div class="zonatexto"><!-- InstanceBeginEditable name="contenidopagina" -->
  <h1>Lista de Productos</h1>
  <?php if ($totalRows_rsproductos 0) { // Show if recordset not empty ?>
    <table border="0" cellpadding="0" cellspacing="0" class="cuadricula">
      
      <?php do { ?>
      
      <?php if($contador $columnas==0) {  ?>
        <tr>
      <?php ?>
          <td width="152"><table width="120" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><?php echo $row_rsproductos['NombreProducto']; ?></td>
            </tr>
            <tr>
              <td><a href="productodetalles.php?codigodetalle=<?php echo $row_rsproductos['IdProducto']; ?>"><img name="" src="<?php echo $row_rsproductos['imagenchica']; ?>" alt="" /></a></td>
            </tr>
            <tr>
              <td>Precio: S/.<?php echo number_format($row_rsproductos['PrecioUnidad'],2); ?></td>
            </tr>
            <tr>
              <td><form id="form1" name="form1" method="post" action="carritodecomprasagregar.php">
                Cantidad:
                              <input name="cantidad" type="text" id="cantidad" size="5" />
                              <input type="image" name="imageField" id="imageField" src="imagenes/iconos/vercarrito.gif" />
                              <input type="hidden" name="codigoProducto" id="codigoProducto" value="<?php echo $row_rsproductos['IdProducto']; ?>"/>
              </form>                </td>
            </tr>
          </table>
            </td>
          <?php 
                  $contador
++;
                  if(
$contador $columnas==0) {  ?>
              </tr>
                  <?php ?>

        <?php } while ($row_rsproductos mysql_fetch_assoc($rsproductos)); ?>
    </table>
        <?php // Show if recordset not empty ?>
        <?php if ($totalRows_rsproductos == 0) { // Show if recordset empty ?>
          <table border="0" cellpadding="0" cellspacing="0" class="cuadricula">
            
            <?php do { ?>
                  <?php if($contador $columnas==0) {  ?>

              <tr>
                    <?php ?>

                <td><table width="120" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><?php echo $row_rsOferta['NombreProducto']; ?></td>
                  </tr>
                  <tr>
                    <td><a href="productodetalles.php?codigodetalle=<?php echo $row_rsOferta['IdProducto']; ?>">
                        <img name="" src="<?php echo $row_rsOferta['imagenchica']; ?>" alt="" /></a></td>
                  </tr>
                  <tr>
                    <td>Precio: S/.<?php echo number_format($row_rsOferta['PrecioUnidad'],2); ?></td>
                  </tr>
                  <tr>
                    <td><form id="form2" name="form2" method="post" action="carritodecomprasagregar.php">
                      Cantidad:
                                          <input name="cantidad2" type="text" id="cantidad2" size="5" />
                                          <input type="image" name="imageField2" id="imageField2" src="imagenes/iconos/vercarrito.gif" />
                                          <input name="codigoProducto" type="hidden" id="codigoProducto" value="<?php echo $row_rsOferta['IdProducto']; ?>" />
                    </form>                      </td>
                  </tr>
                </table>                  </td>
                <?php 
                  $contador
++;
                  if(
$contador $columnas==0) {  ?>
              </tr>
                    <?php ?>

              <?php } while ($row_rsOferta mysql_fetch_assoc($rsOferta)); ?>
          </table>
          <br />
          <?php // Show if recordset empty ?>
<br />

<!-- InstanceEndEditable --></div>
</div>
</div>
<div class="anularflotarizquierda"></div>
<div class="piepagina">Av. La Marina 3456 San Miguel - Lima Per&ugrave;<br />
Telefono (511) - 5632514</div>

</div>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result
($rsproductos);
mysql_free_result($rsOferta);
?>
y productodetalle.php es donde deberia aparecer lo buscado en este caso ...
Código PHP:
$colname_rsproductos "-1";
if (isset(
$_GET['codigodetalle'])) {
  
$colname_rsproductos $_GET['codigodetalle']; 
agradeceria su respuesta supongo que el dilema es poner
Código PHP:
codigodetalle=<?php echo $row_rsproductos['IdProducto']; ?>
y
Código PHP:
codigodetalle=<?php echo $row_rsOfertas['IdProducto']; ?>
como una misma o nose talvez dos por separado (no se como) en
Código PHP:
$colname_rsproductos "-1";
if (isset(
$_GET['codigodetalle'])) {
  
$colname_rsproductos $_GET['codigodetalle'];

para despues como hacer el mostrado