Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/07/2012, 09:09
juniorhernandezg
 
Fecha de Ingreso: enero-2012
Mensajes: 109
Antigüedad: 12 años, 3 meses
Puntos: 0
Mostrar datos de otra tabla

Buenas,

Amigos necesito mostar en la columna CANTIDADES INSTALADAS necesito mostrar los productos instalados pero están en otra tabla llamada PRIORIDAD.

Estructura BD PRIORIDAD:
Código MySQL:
Ver original
  1. codma | cant_inst
  2. 1 | 32
  3. 2 | 24

El codma es un id que podemos relacionarlo con cod_m de la primera tabla llamada INVENTARIO.


Estructura BD INVENTARIO:
Código MySQL:
Ver original
  1. Equipo, Nombre, cod_m
  2. RNC, Tarjeta, 1
  3. RNC, Tarjeta, 1

Como podría mostrar las cantidades instaladas según esa relacion de ID. Necesito listarla en la tabla en la columna CANTIDADES INSTALADAS.

Donde dice CANTIDADES EN DEPOSITO me imprime 2 ya que son dos productos con el mismo cod_m

Codigo PHP:

Código PHP:
<?php  
  $host 
="localhost";
  
$user ="root";
  
$password ="2012";
  
$db ="deposito";
    
$enlace mysql_connect($host,$user,$password);
    
mysql_select_db($db,$enlace);
    
$consulta mysql_query("SELECT cod_m,equipo,nombre,(count(cod_m)) as total from inventario group by nombre",$enlace);

  
  echo 
"<table width='100%'>"

      echo 
"<thead>"
    echo 
"<tr>";     
    echo 
"<th width='10%'>Equipo</th>";
    echo 
"<th width='40%'>Nombre</th>";
    echo 
"<th width='10%'>Cod Material</th>";
    echo 
"<th width='5%'>Cant. Instaladas</th>";
    echo 
"<th width='5%'>Cant. en Deposito</th>";
    echo 
"<th width='10%'>Solicitar (SI/NO)</th>";
    echo 
"</tr>";
        
  
  while (
$row mysql_fetch_array($consulta)) 
  
  {
      echo 
"<tr>\n";
      echo 
"<td width='10%'>" $row["equipo"] . "</td>\n";
      echo 
"<td width='40%'>" $row["nombre"] . "</td>\n";
      echo 
"<td width='10%'>" $row["cod_m"] . "</td>\n";
      echo 
"<td width='5%'>" $row["cant_inst"] . "</td>\n";
      echo 
"<td width='5%'>" $row["total"] . "</td>\n";
      echo 
"<td width='10%'>" . (($row["total"] >= ($row["cant_inst"] * 10/100)) ? 'NO' 'SI') . "</td>\n";
      echo 
"</tr>";
     }
    echo 
"</table>"
    
?>