PHP - Echo no obedece el orden que le estoy dando

 
Vista:
sin imagen de perfil

Echo no obedece el orden que le estoy dando

Publicado por Sebastian (1 intervención) el 17/04/2018 07:30:52
Hola a todos.
Tengo varios problemas respecto a echo
estoy programando un php que me extraiga los datos desde una DB
pero al querer mostrarlos no se que sucede que me aparecen mas <br> de los que se supone tengo e incluso aparecen dos "> " que nisiquiera he puesto
la pagina extrae bien los datos, lo que sucede es que me muestra mal los datos
no se que pueda ser
(adjunto imagen con lo que muestra la pagina)

este es mi codigo

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
	//conectamos Con el servidor
	$conectar=mysqli_connect('localhost','root','');
	//verificamos la conexion
	if(!$conectar){
		echo"No Se Pudo Conectar Con El Servidor";
	}else{
 
		$base=mysqli_select_db($conectar,'control_electrico');
		if(!$base){
			echo"No Se Encontro La Base De Datos";
		}
	}
	//recuperar las variables
	$rut=(int)$_POST['rut'];
	//hacemos la sentencia de sql
 
	$sqlcliente="SELECT `nombre`, `rut`, `comuna`, `latitud`, `longitud`, `email`, `comentario`, `energiacliente_numcliente`, `instalacion_instalacion_id` FROM `cliente` WHERE rut = $rut ";
 
	$sqlenergiacliente="SELECT `distribuidor`, `numcliente`, `costoenergia`, `cliente_rut` FROM `energiacliente` WHERE cliente_rut = $rut ";
 
	$sqlinstalacion="SELECT `kwhkwp`, `kwpinstalado`, `inversionfv`, `iogenglp`, `ioobrasciv`, `potmodukwp`, `cliente_rut`, `instalacion_id` FROM `instalacion` WHERE cliente_rut = $rut ";
 
	$sqlbanco="SELECT `nummeses`, `cuotaanual`, `totalinvusd`, `cliente_rut` FROM `banco` WHERE cliente_rut = $rut ";
 
	//ejecutamos la sentencia de sql
	$dato_cliente=mysqli_query($conectar,$sqlcliente);
	$dato_energia=mysqli_query($conectar,$sqlenergiacliente);
	$dato_instalacion=mysqli_query($conectar,$sqlinstalacion);
	$dato_banco=mysqli_query($conectar,$sqlbanco);
 
	//verificamos la ejecucion
 
	if(!$dato_cliente && !$dato_energia && !$dato_instalacion && !$dato_banco){
		echo"Hubo Algun Error buscando $rut";
	}else{
		echo "<table border = '1'> <br>";
		echo "<tr> <td>Rut</td> <td>Nombre</td> <td>Comuna</td> <td>E-mail</td> <td>Comentario</td> </tr> <br>";
		while ($row1 = mysqli_fetch_array($dato_cliente)) {
    		echo "<tr> <td>$row1[1]</td> <td>$row1[0]</td> <td>$row1[2]</td> <td>$row1[5]</td> <td>$row1[6]</td> </tr> <br>";
		}
		echo "<table border = '1'> <br>";
		echo "<tr> <td>Distribuidor</td> <td>Numero Cliente</td> <td>Costo Energia</td>> </tr><br>";
		while ($row2 = mysqli_fetch_array($dato_energia)) {
    		echo "<tr> <td>$row2[0]</td> <td>$row2[1]</td> <td>$row2[2]</td> </tr> <br>";
		}
		echo "<table border = '1'> <br>";
		echo "<tr> <td>Kwh/Kwp</td> <td>Kwp Instalado</td> <td>Inversion FV</td> <td>Pot Modulo Kwp</td> </tr> <br>";
		while ($row3 = mysqli_fetch_array($dato_instalacion)) {
    		echo "<tr> <td>$row3[0]</td> <td>$row3[1]</td> <td>$row3[2]</td> <td>$row3[5]</td> </tr> <br>";
		}
		echo "<table border = '1'> <br>";
		echo "<tr> <td>Numero de anios</td> <td>Cuota Anual</td> <td>Total Inversion USD</td>> </tr><br>";
		while ($row4 = mysqli_fetch_array($dato_banco)) {
    		echo "<tr> <td>$row4[0]</td> <td>$row4[1]</td> <td>$row4[2]</td> </tr><br>";
		}
		echo "<br>Todo OK<br><br><a href='mostrar.html'>Volver al buscador</a><br><br><a href='index.html'>Volver a Inicio</a>";
	}
?>


ErrorEcho
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
Imágen de perfil de Javi
Val: 10
Ha aumentado su posición en 17 puestos en PHP (en relación al último mes)
Gráfica de PHP

Echo no obedece el orden que le estoy dando

Publicado por Javi (5 intervenciones) el 17/04/2018 11:07:22
Hola Sebastián, los ">" que te aparecen de más es por esta línea:
echo "<tr> <td>Numero de anios</td> <td>Cuota Anual</td> <td>Total Inversion USD</td>> </tr><br>";
le has puesto uno de más.
Yo no controlo mucho la verdad, pero creo que sería algo así:
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
//conectamos Con el servidor
$conectar=mysqli_connect('localhost','root','');
//verificamos la conexion
if(!$conectar){
echo 'No Se Pudo Conectar Con El Servidor';
}else{
 
$base=mysqli_select_db($conectar,'control_electrico');
if(!$base){
echo 'No Se Encontro La Base De Datos';
}
}
//recuperar las variables
$rut=(int)$_POST['rut'];
//hacemos la sentencia de sql
 
$sqlcliente="SELECT 'nombre', 'rut', 'comuna', 'latitud', 'longitud', 'email', 'comentario', 'energiacliente_numcliente', 'instalacion_instalacion_id' FROM 'cliente' WHERE rut = $rut ";
 
$sqlenergiacliente="SELECT 'distribuidor', 'numcliente', 'costoenergia', 'cliente_rut' FROM 'energiacliente' WHERE cliente_rut = $rut ";
 
$sqlinstalacion="SELECT 'kwhkwp', 'kwpinstalado', 'inversionfv', 'iogenglp', 'ioobrasciv', 'potmodukwp', 'cliente_rut', 'instalacion_id' FROM 'instalacion' WHERE cliente_rut = $rut ";
 
$sqlbanco="SELECT 'nummeses', 'cuotaanual', 'totalinvusd', 'cliente_rut' FROM 'banco' WHERE cliente_rut = $rut ";
 
//ejecutamos la sentencia de sql
$dato_cliente=mysqli_query($conectar,$sqlcliente);
$dato_energia=mysqli_query($conectar,$sqlenergiacliente);
$dato_instalacion=mysqli_query($conectar,$sqlinstalacion);
$dato_banco=mysqli_query($conectar,$sqlbanco);
 
//verificamos la ejecucion
 
if(!$dato_cliente && !$dato_energia && !$dato_instalacion && !$dato_banco){
echo 'Hubo Algun Error buscando' .$rut;
}else{
echo '<table style="border: 1px;"> <br>';
echo '<tr>
        <td>Rut</td> 
        <td>Nombre</td> 
        <td>Comuna</td> 
        <td>E-mail</td> 
        <td>Comentario</td> 
      </tr> <br>';
while ($row1 = mysqli_fetch_array($dato_cliente)) {
echo '<tr>
        <td>'.$row1[1].'</td>
        <td>'.$row1[0].'</td>
        <td>'.$row1[2].'</td>
        <td>'.$row1[5].'</td>
        <td>'.$row1[6].'</td>
      </tr> <br>';
}
echo '<table style="border: 1px;"> <br>';
echo '<tr>
        <td>Distribuidor</td> 
        <td>Numero Cliente</td> 
        <td>Costo Energia</td>> 
      </tr><br>';
while ($row2 = mysqli_fetch_array($dato_energia)) {
echo '<tr>
        <td>'.$row2[0].'</td>
        <td>'.$row2[1].'</td>
        <td>'.$row2[2].'</td>
      </tr> <br>';
}
echo '<table style="border: 1px;"> <br>';
echo '<tr>
        <td>Kwh/Kwp</td> 
        <td>Kwp Instalado</td> 
        <td>Inversion FV</td> 
        <td>Pot Modulo Kwp</td> 
      </tr> <br>';
while ($row3 = mysqli_fetch_array($dato_instalacion)) {
echo '<tr>
        <td>'.$row3[0].'</td>
        <td>'.$row3[1].'</td>
        <td>'.$row3[2].'</td>
        <td>'.$row3[5].'</td>
       </tr> <br>';
}
echo '<table style="border: 1px;"> <br>';
echo '<tr>
        <td>Numero de anios</td> 
        <td>Cuota Anual</td> 
        <td>Total Inversion USD</td> 
       </tr><br>';
while ($row4 = mysqli_fetch_array($dato_banco)) {
echo '<tr>
        <td>'.$row4[0].'</td>
        <td>'.$row4[1].'</td>
        <td>'.$row4[2].'</td>
      </tr><br>';
}
echo '<br>Todo OK<br>
      <br><a href="mostrar.html">Volver al buscador</a><br>
      <br><a href="index.html">Volver a Inicio</a>';
}
?>

Saludos.
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
Imágen de perfil de Javi
Val: 10
Ha aumentado su posición en 17 puestos en PHP (en relación al último mes)
Gráfica de PHP

Echo no obedece el orden que le estoy dando

Publicado por Javi (5 intervenciones) el 17/04/2018 11:10:02
Ahora me he comido yo el último corchete de code XD

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
//conectamos Con el servidor
$conectar=mysqli_connect('localhost','root','');
//verificamos la conexion
if(!$conectar){
echo 'No Se Pudo Conectar Con El Servidor';
}else{
 
$base=mysqli_select_db($conectar,'control_electrico');
if(!$base){
echo 'No Se Encontro La Base De Datos';
}
}
//recuperar las variables
$rut=(int)$_POST['rut'];
//hacemos la sentencia de sql
 
$sqlcliente="SELECT 'nombre', 'rut', 'comuna', 'latitud', 'longitud', 'email', 'comentario', 'energiacliente_numcliente', 'instalacion_instalacion_id' FROM 'cliente' WHERE rut = $rut ";
 
$sqlenergiacliente="SELECT 'distribuidor', 'numcliente', 'costoenergia', 'cliente_rut' FROM 'energiacliente' WHERE cliente_rut = $rut ";
 
$sqlinstalacion="SELECT 'kwhkwp', 'kwpinstalado', 'inversionfv', 'iogenglp', 'ioobrasciv', 'potmodukwp', 'cliente_rut', 'instalacion_id' FROM 'instalacion' WHERE cliente_rut = $rut ";
 
$sqlbanco="SELECT 'nummeses', 'cuotaanual', 'totalinvusd', 'cliente_rut' FROM 'banco' WHERE cliente_rut = $rut ";
 
//ejecutamos la sentencia de sql
$dato_cliente=mysqli_query($conectar,$sqlcliente);
$dato_energia=mysqli_query($conectar,$sqlenergiacliente);
$dato_instalacion=mysqli_query($conectar,$sqlinstalacion);
$dato_banco=mysqli_query($conectar,$sqlbanco);
 
//verificamos la ejecucion
 
if(!$dato_cliente && !$dato_energia && !$dato_instalacion && !$dato_banco){
echo 'Hubo Algun Error buscando' .$rut;
}else{
echo '<table style="border: 1px;"> <br>';
echo '<tr>
        <td>Rut</td> 
        <td>Nombre</td> 
        <td>Comuna</td> 
        <td>E-mail</td> 
        <td>Comentario</td> 
      </tr> <br>';
while ($row1 = mysqli_fetch_array($dato_cliente)) {
echo '<tr>
        <td>'.$row1[1].'</td>
        <td>'.$row1[0].'</td>
        <td>'.$row1[2].'</td>
        <td>'.$row1[5].'</td>
        <td>'.$row1[6].'</td>
      </tr> <br>';
}
echo '<table style="border: 1px;"> <br>';
echo '<tr>
        <td>Distribuidor</td> 
        <td>Numero Cliente</td> 
        <td>Costo Energia</td>> 
      </tr><br>';
while ($row2 = mysqli_fetch_array($dato_energia)) {
echo '<tr>
        <td>'.$row2[0].'</td>
        <td>'.$row2[1].'</td>
        <td>'.$row2[2].'</td>
      </tr> <br>';
}
echo '<table style="border: 1px;"> <br>';
echo '<tr>
        <td>Kwh/Kwp</td> 
        <td>Kwp Instalado</td> 
        <td>Inversion FV</td> 
        <td>Pot Modulo Kwp</td> 
      </tr> <br>';
while ($row3 = mysqli_fetch_array($dato_instalacion)) {
echo '<tr>
        <td>'.$row3[0].'</td>
        <td>'.$row3[1].'</td>
        <td>'.$row3[2].'</td>
        <td>'.$row3[5].'</td>
       </tr> <br>';
}
echo '<table style="border: 1px;"> <br>';
echo '<tr>
        <td>Numero de anios</td> 
        <td>Cuota Anual</td> 
        <td>Total Inversion USD</td> 
       </tr><br>';
while ($row4 = mysqli_fetch_array($dato_banco)) {
echo '<tr>
        <td>'.$row4[0].'</td>
        <td>'.$row4[1].'</td>
        <td>'.$row4[2].'</td>
      </tr><br>';
}
echo '<br>Todo OK<br>
      <br><a href="mostrar.html">Volver al buscador</a><br>
      <br><a href="index.html">Volver a Inicio</a>';
}
?>
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