Cuando ponemos que nos muestre un piloto concreto en este caso 0377 sale correcto, el vuelo ANT-1 aceptado (valor 1)y el ANT-2 rechazado (valor 2). Estas peticiones hacemos una por cada vuelo, ANT-1, ANT-2, etc. Si participan diez pilotos tendríamos que hacer esto diez veces sabiendo de antemano cuales participan para añadirlos al código.
Entonces si borramos = '0377' nos muestra todos los pilotos automáticamente que han hecho alguno de esos vuelos pero lo hace incorrectamente, ya que por ejemplo el 0377 tiene marcado el ANT-2 como rechazado (valor 2) y a todos les pone aceptado (valor 1) sea verdad o no.
Código PHP:
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_byethost, $byethost);
$query_tabladetours = "SELECT `phpvms_pireps`.`pilotid`, `phpvms_pireps`.`accepted` FROM phpvms_pireps WHERE ((`phpvms_pireps`.`pilotid` = '0377') AND (`phpvms_pireps`.`flightnum` = 'ANT-1') AND (`phpvms_pireps`.`accepted`)) ORDER BY `phpvms_pireps`.`pilotid` ASC , `phpvms_pireps`.`flightnum` ASC , `phpvms_pireps`.`accepted` ASC LIMIT 0 , 30";
$tabladetours = mysql_query($query_tabladetours, $byethost) or die(mysql_error());
$row_tabladetours = mysql_fetch_assoc($tabladetours);
$totalRows_tabladetours = mysql_num_rows($tabladetours);
mysql_select_db($database_byethost, $byethost);
$query_tabladetours1 ="SELECT `phpvms_pireps`.`pilotid`, `phpvms_pireps`.`accepted` FROM phpvms_pireps WHERE ((`phpvms_pireps`.`pilotid` = '0377') AND (`phpvms_pireps`.`flightnum` = 'ANT-2') AND (`phpvms_pireps`.`accepted`)) ORDER BY `phpvms_pireps`.`pilotid` ASC , `phpvms_pireps`.`flightnum` ASC , `phpvms_pireps`.`accepted` ASC LIMIT 0 , 30";
$tabladetours1= mysql_query($query_tabladetours1, $byethost) or die(mysql_error());
$row_tabladetours1= mysql_fetch_assoc($tabladetours1);
$totalRows_tabladetours1= mysql_num_rows($tabladetours1);
mysql_select_db($database_byethost, $byethost);
$query_tabladetours2 ="SELECT `phpvms_pireps`.`pilotid`, `phpvms_pireps`.`accepted` FROM phpvms_pireps WHERE ((`phpvms_pireps`.`pilotid` = '0377') AND (`phpvms_pireps`.`flightnum` = 'ANT-3') AND (`phpvms_pireps`.`accepted`)) ORDER BY `phpvms_pireps`.`pilotid` ASC , `phpvms_pireps`.`flightnum` ASC , `phpvms_pireps`.`accepted` ASC LIMIT 0 , 30";
$tabladetours2= mysql_query($query_tabladetours2, $byethost) or die(mysql_error());
$row_tabladetours2= mysql_fetch_assoc($tabladetours2);
$totalRows_tabladetours2= mysql_num_rows($tabladetours2);
mysql_select_db($database_byethost, $byethost);
$query_tabladetours3 ="SELECT `phpvms_pireps`.`pilotid`, `phpvms_pireps`.`accepted` FROM phpvms_pireps WHERE ((`phpvms_pireps`.`pilotid` = '0377') AND (`phpvms_pireps`.`flightnum` = 'ANT-4') AND (`phpvms_pireps`.`accepted`)) ORDER BY `phpvms_pireps`.`pilotid` ASC , `phpvms_pireps`.`flightnum` ASC , `phpvms_pireps`.`accepted` ASC LIMIT 0 , 30";
$tabladetours3= mysql_query($query_tabladetours3, $byethost) or die(mysql_error());
$row_tabladetours3= mysql_fetch_assoc($tabladetours3);
$totalRows_tabladetours3= mysql_num_rows($tabladetours3);
?>
<table border="5" align="left">
<tr>
<td bgcolor="#CC3300"><div align="center"><strong>ID de piloto ARV:</strong></div></td>
<td bgcolor="#CC3300"><div align="center"><strong>ANT-1</strong></div></td>
<td bgcolor="#CC3300"><div align="center"><strong>ANT-2</strong></div></td>
<td bgcolor="#CC3300"><div align="center"><strong>ANT-3</strong></div></td>
<td bgcolor="#CC3300"><div align="center"><strong>ANT-4</strong></div></td>
</div></td>
</tr>
<?php do { ?>
<tr>
<td bgcolor="#FFFFFF"><strong>ARV</strong><?php echo $row_tabladetours['pilotid']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $row_tabladetours['accepted']; ?><?php
if($row_tabladetours['accepted']=='1'){
echo ("<img src='http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistobueno.gif'>");
}
elseif($row_tabladetours['accepted']=='2'){
echo ("<img src='http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistomalo.png'>");
}
else{
echo("No mostar nada");}
?></td>
<td bgcolor="#FFFFFF"><?php echo $row_tabladetours1['accepted']; ?><?php
if($row_tabladetours1['accepted']=='1'){
echo ("<img src='http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistobueno.gif'>");
}
elseif($row_tabladetours1['accepted']=='2'){
echo ("<img src='http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistomalo.png'>");
}
else{
echo("No mostar nada");}
?></td>
<td bgcolor="#FFFFFF"><?php echo $row_tabladetours2['accepted']; ?><?php
if($row_tabladetours2['accepted']=='1'){
echo ("<img src='http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistobueno.gif'>");
}
elseif($row_tabladetours2['accepted']=='2'){
echo ("<img src='http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistomalo.png'>");
}
else{
echo("No mostar nada");}
?></td>
<td bgcolor="#FFFFFF"><?php echo $row_tabladetours3['accepted']; ?><?php
if($row_tabladetours3['accepted']=='1'){
echo ("<img src='http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistobueno.gif'>");
}
elseif($row_tabladetours3['accepted']=='2'){
echo ("<img src='http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistomalo.png'>");
}
else{
echo("No mostar nada");}
?></td>
</tr>
<?php } while ($row_tabladetours = mysql_fetch_assoc($tabladetours));
while ($row_tabladetours1 = mysql_fetch_assoc($tabladetours1));
while ($row_tabladetours2 = mysql_fetch_assoc($tabladetours2));
while ($row_tabladetours3 = mysql_fetch_assoc($tabladetours3));?>
</table>
<?php
mysql_free_result($tabladetours);
mysql_free_result($tabladetours1);
mysql_free_result($tabladetours2);
mysql_free_result($tabladetours3);
?>