text-decoration: none;
}
a:hover {
	color: #FC0;
	text-decoration: underline;
}
a:active {
	color: white;
	text-decoration: none;
}
a:link {
	text-decoration: none;
}
</style>
<?
$datos=$db->extraer("select * from tip_hab where act=1 ORDER BY orden_entrada");
?>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="40%">&nbsp;</td>
    <td width="30%"><strong>Promo</strong></td>
    <td width="30%"><strong>Sin Promo</strong></td>
  </tr>
  <?
  foreach($datos as $dt){
     $id=$dt['id_tip'];
	 $tipo=$dt['tip'];
	 $sql="select *,concat(hour(tie),'.',minute(tie)) as tiempo from pro 
	 INNER JOIN tip_hab ON pro.tip=tip_hab.id_tip where dia=$dia and hor=$hora
	 and tip_hab.id_tip=$id";
	 
/*
CASE dia
WHEN 1 THEN 'LUN A JUEV'
WHEN 2 THEN 'VIE Y SAB'
WHEN 3 THEN 'DOMINGO'
END AS dia_lis,

CASE hor
WHEN 1 THEN '8 A 14 HS'
WHEN 2 THEN '14 A 8 HS'
WHEN 3 THEN '00 A 8 HS'
END AS hor_lis
*/

$sql="select *,concat(hour(tie),'.',minute(tie)) as tiempo from pro where dia=$dia and hor=$hora";
$hab=$db->extraer($sql);
$i=1;

foreach($hab as $a){
	
	if ($a['promo_hab']==1){
		if ($i<>1){echo '&';}
		echo 'varPromo_'.$a['tip'].'='.$a['tiempo']."hs $".$a['val'];
	}else{
		if ($i<>1){echo '&';}
		echo 'varOriginal_'.$a['tip'].'='.$a['tiempo']."hs $".$a['val'];
	}
	
	$i++;
}