Listar resultados bd
Publicado por josema (9 intervenciones) el 09/03/2018 19:45:47
Hola, tengo este código, parece sencillo pero estoy atascado 
Lo que quiero es sacar los datos por pantalla, pero al ejecutarlo me da error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\select\consulta.php on line 21
La línea 21 es: while ($registro = mysql_fetch_array($result)){
Ayuda pleaseeeeeee

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
<html>
<head>
<TITLE>Muestra los resultados de una consulta MySQL.</TITLE>
</head>
<body>
<div align='center'>
<table border='1' cellpadding='0' cellspacing='0' width='600' bgcolor='#F6F6F6' bordercolor='#FFFFFF'>
<tr>
<td width='150' style='font-weight: bold' align='center'>Numero</td>
<td width='150' style='font-weight: bold' align='center'>Comunidad Autonoma</td>
<td style='font-weight: bold' align='center'>Tipo</td>
</tr>
<?php
include('abre_conexion.php');
$query = "select * from $tabla_db1"; // Esta linea hace la consulta
$result = mysql_query($query);
while ($registro = mysql_fetch_array($result)){
echo "
<tr>
<td width='150' align='center'>".$registro['numero']."</td>
<td width='150' align='center'>".$registro['ccaa']."</td>
<td align='center'>".$registro['tipo']."</td>
</tr>
";
}
include('cierra_conexion.php');
?>
</table>
</div>
</body>
</html>
Lo que quiero es sacar los datos por pantalla, pero al ejecutarlo me da error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\select\consulta.php on line 21
La línea 21 es: while ($registro = mysql_fetch_array($result)){
Ayuda pleaseeeeeee
Valora esta pregunta


0