Ver Mensaje Individual
  #2 (permalink)  
Antiguo 31/12/2011, 10:32
leonagelic
Usuario no validado
 
Fecha de Ingreso: enero-2010
Ubicación: Maturín, Monagas
Mensajes: 190
Antigüedad: 14 años, 3 meses
Puntos: 24
Respuesta: Consulta a dos tablas BD

no hagas 2 bucles, en ese mismo while inserta la consulta de la segunda tabla e imprime el resultado algo asi lo haria

Código PHP:
Ver original
  1. $result=mysql_query("SELECT * FROM productos ORDER BY id_producto asc");
  2. while($row=mysql_fetch_row($result))
  3. {
  4. $result2=mysql_query("SELECT * FROM categoria where id_categoria = '".$row['4']."'");
  5. $ro=mysql_fetch_row($result2);
  6.  
  7. echo "
  8. <tr style='font-size:9px;'>
  9. <th>$row[1]</th>
  10. <th >$row[2] Bs.</th>
  11. <th>$row[3] </th>
  12. <th>$ro[1] </th>
  13. <th><img width=68 height=58  src='$url'></th>
  14. <th>
  15. <a href=editar.php?id=$row[0] title=editar><img src=001_45.gif width=18/></a>
  16. <a href=borrar.php?id=$row[0] title=borrar><img src=001_49.gif  width=18/></a>
  17.  
  18. </th>
  19. </tr>";


Espero te sirva.