Ver Mensaje Individual
  #6 (permalink)  
Antiguo 09/05/2005, 02:05
eras77
 
Fecha de Ingreso: abril-2005
Mensajes: 14
Antigüedad: 19 años
Puntos: 0
codigo hecho

queria agradecersu ayuda a jam1138 q me facilitola funcion color y me abrio el camino

a final he usado este codigo, q os parece?

function conectar($servidor, $usuario, $password, $base_datos)
{
if (!($link=mysql_connect($servidor,$usuario,$passwor d)))
{
exit();
}
if(!(mysql_select_db($base_datos,$link)))
{
exit();
}
return $link;
}

$conexion = conectar("","usuariomysql","passmysql","basededato s");

<?

function color($valor) {
if(!is_int($valor)) return false;
else if($valor<=3)
{
switch($valor)
{
case 0: return "WHITE"; break;
case 1: return "GREEN"; break;
case 2: return "YELLOW"; break;
case 3: return "RED"; break;
}
}
}

function alarmes_cn($date_app){
$sql = mysql_query("select cn.IdCn,cn.Date,concerne.Date_App,concerne.IdCn from cn,concerne where cn.IdCn==concerne.IdCn && Concerne.Date_App=".$date_app,$conexion);
while($row = mysql_fetch_array($sql))
{
$Date =$row["Date"];
$Date_App= $row["Date_App"];
}
$Dias_totales=(strtotime($DateApp)-strtotime($Date))/(60*60*24);
$Dias_transcurridos=(strtotime(date("Y-m-d"))-strtotime($Date));
$Porcentaje_completado=$Dias_transcurridos*100/$Dias_totales;
$Porcentaje_restante=100-$Porcentaje_completado;
if ($Date_App==NULL)
{
return color(0);
}
else if ($Porcentaje_restante <= 0)
{
return color(3);
}
else if ($Porcentaje_restante <= 10)
{
return color(2);
}
else
{
return color(1);
}
}

function alarmes_visite($pot)
{
$sql = mysql_query("select cdv.DateV,cdv.DureeV,cdv.Immatriculation,passe.Dat e,passe.Immatriculation from cdv,passe where cdv.Immatriculation==passe.Immatriculation && passe.Potentiel=".$pot,$conexion);
while($row = mysql_fetch_array($sql))
{
$DateV = $row["DateV"];
$DureeV = $row["DureeV"];
$Date = $row["Date"];
}
$Dias_permanencia=(strtotime($Date)-strtotime($DateV))/(60*60*24);
$Porcentaje_permanencia=$Dias_permanencia*100/DureeV;
$Porcentaje_restante=100-$Porcentaje_permanencia;
if ($Porcentaje_restante <= 0)
{
return color(3);
}
else if ($Porcentaje_restante <= 10)
{
return color(2);
}
else
{
return color(1);
}
}

function alarmes_equipement($pc)
{
$sql = mysql_query("select avion.Immatriculation,equipement.Pot_Cal,equipemen t.Pot_Duree,equipement.Immatriculation from avion,equipement where avion.Immatriculation==equipement.Immatriculation && equipement.Pot_Cal=".$pc,$conexion);
while($row = mysql_fetch_array($sql))
{
$Pot_Duree = $row["Pot_Duree"];
}
$Porcentaje_pc=$pc*100/$Pot_Duree;
$Porcentaje_restante=100-Porcentaje_pc;
if ($Porcentaje_restante <= 0)
{
return color(3);
}
else
{
if ($Porcentaje_restante <= 10)
{
return color(2);
}
else
{
return color(1);
}
}
}


?>

saludos