Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/01/2015, 06:11
spark21
 
Fecha de Ingreso: diciembre-2007
Mensajes: 38
Antigüedad: 16 años, 4 meses
Puntos: 1
else if echo imagen en tabla

Hola, estamos intentando crear una tabla que devuelva unos resultados de la base de datos, hasta ahí bien, el problema es que queremos que nos muestre una imagen alojada en el servidor, si el valor de la consulta es 1 muestre vistobueno.jpg, si es 2 muestre vistomalo.png, y si no es ninguno de los dos aparezca en blanco, nada.

Os dejo el código y la url:

http://www.argavirtual.com/lib/skins/TABLA%20DE%20JOSE.php

Código:
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` ='1')) 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` ='1')) 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` ='1')) 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` ='1')) 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);
Código:
<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']; ?><img src='http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistobueno.gif'></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''></img>";}
  elseif ($row_tabladetours1->accepted == 2) {echo "<img src='http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistomalo.png'></img>";}
?></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"></img>';}
  elseif ($row_tabladetours2->accepted == 2){ echo '<img src="http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistomalo.png"></img>';}
?></td>
      <td bgcolor="#FFFFFF"><?php echo $row_tabladetours3['accepted']; ?><img src='http://argavirtual.com/lib/skins/templatemo_254_agency/images/vistobueno.gif'></td> 
    </tr>
    <?php } while ($row_tabladetours = mysql_fetch_assoc($tabladetours));
            while ($row_tabladetours1 = mysql_fetch_assoc($tabladetours1));?>
</table>


<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($tabladetours);
mysql_free_result($tabladetours1);
?>