<html>
<head><title>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</title>
</head>
<body>
<?
 require ("open_db_prod.php" );

 if ( isset( $idp ) )
 {
  $res = @mysql_query( "SELECT p.cprod, p.descr, p.precioVenta1, i.tipo AS iva, p.notas, p.fabricante, p.garantia, p.imgH, p.imgW FROM productos AS p, tipos_iva AS i WHERE p.id=$idp AND i.id=p.tipo_iva",$conexion_prod ) or die(mysql_error($conexion_prod)); 
  if ( @mysql_num_rows($res)>0 )
  {
   list( $db_cprod, $db_descr, $db_pv, $db_iva, $db_notas, $db_fabr, $db_gar, $db_imgH, $db_imgW ) = @mysql_fetch_array( $res );
   echo "<table>".
        "<tr><td colspan=2>".
        "<b>$db_descr</b></td></tr>".
	"<tr><td>";
   echo "<br><b>Código:</b> $db_cprod".
        
	"<br><b>Precio:</b> $db_pv €".
        "<br><b>IVA:</b> $db_iva".
	"<br><b>Garantía:</b> $db_gar meses".
	"<br><b>Fabricante:</b> <a href='$db_fabr' target=_new>$db_fabr</a>";
   echo "</td><td width=300 valign=top>";
   if ( $db_imgH > 0 )
   {
     echo '<img src="getImg.php?idf='.$idp.'" '.resize( $db_imgH, $db_imgW ).'>';
   }
   echo "</td></tr></table>";
   echo "<b>Notas:</b><br> ".nl2br($db_notas)."<br><br><br>";
  }
 }

 mysql_free_result($res);
 mysql_close($conexion);

 function resize($H, $W)
 {
  $nW = 200; $nH = 200;
  $image_prop = "";
  
  if ( $W > 0 )
  {
    if ( !($W < $nW ||$H < $nH ) )
    {
  	if ( $W > $H )
  	{
	  $nH = intval(($H/$W)*$nW);      $image_prop = " width=\"$nW\" height=\"".$nH."\"";
  	} else {
	  $nW = intval(($W/$H)*$nH);	  $image_prop = " height=\"$nH\" width=\"".$nW."\"";
  	}
    } else {
      $image_prop=" width=\"$W\" height=\"$H\"";
    }
  }
  
  return $image_prop;
 } 

?>
</body>
</html>

