
Mostrar total
Publicado por Óscar (3 intervenciones) el 30/01/2016 11:11:38
Buenos días compañeros, soy nuevo en programación en PHP y estoy intentando hacer una especie de web de pedidos de taxis.
Tengo un pequeño problema a la hora de mostrar un dato.
Os dejo parte del código para ver si me podéis orientar un poquillo.
En las últimas líneas si que me muestra los taxis libres, pero el total de taxis me da un Warning: mysqli_affected_rows() expects exactly 1 parameter, 0 given in C:\xampp\
¿Como puedo hacer para mostrar el total de taxis y no solo los disponibles?
Gracias de antemano.
Tengo un pequeño problema a la hora de mostrar un dato.
Os dejo parte del código para ver si me podéis orientar un poquillo.
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>LISTADO GENERAL DE TAXIS</title>
<link rel="stylesheet" href="tabla.css" />
</head>
<body>
<?php
$conexion = @mysqli_connect(.........;
$sel = "SELECT * FROM taxis";
//Ejecutamos la secuencia SQL
$exec = mysqli_query($conexion, $sel);
$libres=0;
?>
<table border="1">
<tr><td>Matrícula</td>
<td>Modelo</td>
<td>Conductor</td>
<td>Ocupado</td>
</tr>
<?php
//Mediante while recorremos la tabla
while ($registro=mysqli_fetch_array($exec)) { //Devuelve el array y rellena los campos
?>
<tr>
<td><?php echo($registro["Matricula"]); ?></td>
<td><?php echo($registro["Modelo"]); ?></td>
<td><?php echo($registro["Nombre"] . " " . $registro["Apellidos"]); ?></td>
<td><?php
if ($registro=="Ocupado")
echo("Si");
else {
$libres++;
echo("No");
}
?></td>
</tr>
<?php
}
//Cerramos la conexión después del bucle
mysqli_close($conexion);
?>
<TR>
<TD COLSPAN="6" align="center"><font color="red"><b>
Taxis Libres: <?php echo($libres);?> - Total Taxis: <?php echo(mysqli_affected_rows()); ?>
</B></font></TD></TR>
</table>
</body>
</html>
En las últimas líneas si que me muestra los taxis libres, pero el total de taxis me da un Warning: mysqli_affected_rows() expects exactly 1 parameter, 0 given in C:\xampp\
¿Como puedo hacer para mostrar el total de taxis y no solo los disponibles?
Gracias de antemano.
Valora esta pregunta


0