Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/10/2011, 09:21
carolina3
 
Fecha de Ingreso: agosto-2011
Ubicación: barcelona
Mensajes: 237
Antigüedad: 12 años, 8 meses
Puntos: 1
mostrar campo de una tabla haciendo referencia a otro

tengo este juego de registros que me muestra las imágenes de una tabla, pero necesitaría que me las mostrara en relación a otro campo que tengo alguien me podría ayudar porfa:


Código PHP:
Ver original
  1. <?php
  2.  
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $maxRows_listadoproductos = 2;
  35. $pageNum_listadoproductos = 0;
  36. if (isset($_GET['pageNum_listadoproductos'])) {
  37.   $pageNum_listadoproductos = $_GET['pageNum_listadoproductos'];
  38. }
  39. $startRow_listadoproductos = $pageNum_listadoproductos * $maxRows_listadoproductos;
  40.  
  41. mysql_select_db($database_blueberryswebtiendas, $blueberryswebtiendas);
  42. $query_listadoproductos = "SELECT * FROM productos";
  43. $query_limit_listadoproductos = sprintf("%s LIMIT %d, %d", $query_listadoproductos, $startRow_listadoproductos, $maxRows_listadoproductos);
  44. $listadoproductos = mysql_query($query_limit_listadoproductos, $blueberryswebtiendas) or die(mysql_error());
  45. $row_listadoproductos = mysql_fetch_assoc($listadoproductos);
  46.  
  47. if (isset($_GET['totalRows_listadoproductos'])) {
  48.   $totalRows_listadoproductos = $_GET['totalRows_listadoproductos'];
  49. } else {
  50.   $all_listadoproductos = mysql_query($query_listadoproductos);
  51.   $totalRows_listadoproductos = mysql_num_rows($all_listadoproductos);
  52. }
  53. $totalPages_listadoproductos = ceil($totalRows_listadoproductos/$maxRows_listadoproductos)-1;
  54. ?>



aquí el resto donde esta la imagen y un do para repetir la región


Código PHP:
Ver original
  1. <?php do { ?>
  2.     <table width="168" height="173" border="1" align="center">
  3.       <tr>
  4.         <td width="158" align="center"><a href="detalle_producto.php?producto_id=<?php echo $row_listadoproductos['producto_id']; ?>"><img src="productos/<?php echo $row_listadoproductos['foto_producto']; ?>" width="134" height="91" /></a></td>
  5.         </tr>
  6.       <tr>
  7.         <td height="23" align="center"><?php echo $row_listadoproductos['nombre_producto']; ?></td>
  8.         </tr>
  9.       <tr>
  10.         <td align="center"><?php echo $row_listadoproductos['precio_producto']; ?></td>
  11.         </tr>
  12.     </table>
  13.     <?php } while ($row_listadoproductos = mysql_fetch_assoc($listadoproductos)); ?>