PHP - tabla, condición y jpg

 
Vista:

tabla, condición y jpg

Publicado por hans (1 intervención) el 13/10/2019 10:37:30
este es mi codigo ya no se que hacer, solo quiero cambia la imagen a rojo(imágenes/rojo.jpg) cuando la velocidad excede 60

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
$tab["1"]=  array(rand(30,90));
$tab["2"]=  array(rand(30,90));
$tab["3"]=  array(rand(30,90));
$tab["4"]=  array(rand(30,90));
$tab["5"]=  array(rand(30,90));
$tab["6"]=  array(rand(30,90));
$tab["7"]=  array(rand(30,90));
$tab["8"]=  array(rand(30,90));
$tab["9"]=  array(rand(30,90));
$tab["10"]=  array(rand(30,90));
$tab["11"]=  array(rand(30,90));
$tab["12"]=  array(rand(30,90));
$tab["13"]=  array(rand(30,90));
$tab["14"]=  array(rand(30,90));
$tab["15"]=  array(rand(30,90));
$tab["16"]=  array(rand(30,90));
$tab["17"]=  array(rand(30,90));
$tab["18"]=  array(rand(30,90));
$tab["19"]=  array(rand(30,90));
$tab["20"]=  array(rand(30,90));
?>
<table>
    <tr><th>codigo<th>velocidad(km/s)<th>exceso<th>imagen
    <?php
       $i=0;
       foreach($tab as $k=>$d){
           if($d[0]>60){
           $exceso=$d[0]-60;
           $i++;
           }else{
           $exceso=0;
           }
           echo "<tr><td>$k<td>$d[0]<td>$exceso<td>";
               ?>
            <img src="imagenes/verde.jpg" height="50" width="50">
        <?php
       }
    ?>
</table>
yudddddddddd
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

tabla, condición y jpg

Publicado por Andres (2 intervenciones) el 13/10/2019 14:27:18
Acá tienes lo que necesitas, lo único que deberías hacer con el código que te envío, es cambiar el nombre y la ruta de las imágenes para poner las tuyas.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
$tab["1"]=  array(rand(30,90));
$tab["2"]=  array(rand(30,90));
$tab["3"]=  array(rand(30,90));
$tab["4"]=  array(rand(30,90));
$tab["5"]=  array(rand(30,90));
$tab["6"]=  array(rand(30,90));
$tab["7"]=  array(rand(30,90));
$tab["8"]=  array(rand(30,90));
$tab["9"]=  array(rand(30,90));
$tab["10"]=  array(rand(30,90));
$tab["11"]=  array(rand(30,90));
$tab["12"]=  array(rand(30,90));
$tab["13"]=  array(rand(30,90));
$tab["14"]=  array(rand(30,90));
$tab["15"]=  array(rand(30,90));
$tab["16"]=  array(rand(30,90));
$tab["17"]=  array(rand(30,90));
$tab["18"]=  array(rand(30,90));
$tab["19"]=  array(rand(30,90));
$tab["20"]=  array(rand(30,90));
?>
<table>
    <tr><th>codigo<th>velocidad(km/s)<th>exceso<th>imagen
    <?php
       foreach($tab as $k=>$d){
           if($d[0]>60){
	           $exceso=$d[0]-60;
	           echo "<tr><td>$k<td>$d[0]<td>$exceso<td>";
	           echo '<img src="image/rojo.png" height="50" width="50">';
           }else{
	           $exceso=0;
	           echo "<tr><td>$k<td>$d[0]<td>$exceso<td>";
	           echo '<img src="image/verde.png" height="50" width="50">';
           }
       }
    ?>
</table>
Screenshot_97
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar