No me anda el foreach me da error ilegal string ...
Publicado por Joel (9 intervenciones) el 27/04/2018 02:45:08
El forech me da error y no me muestra la tabla con los datos. Tienen idea de como solucionarlo. Gracias!
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
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<?php
require_once 'conexion.php';
include_once 'head.php';
?>
<title>Centro de Noticias</title>
</head>
<body>
<?php
$sql= "SELECT titulo, subtitulo, resumen, noticias, imagen FROM noticiastb";
$resultado=mysqli_query($con, $sql);
if (mysqli_num_rows($resultado) > 0){
$datos= mysqli_fetch_assoc($resultado);
//$datos2= mysqli_fetch_all($resultado);
} else { echo "No hay Noticia";}
?>
<br>
<table border="1">
<thead>
<br>
<tr>
<th>TITULO </th>
<th>SUBTITULO </th>
<th>RESUMEN </th>
<th>NOTICIA </th>
<th>IMAGEN</th>
</tr>
</thead>
<?php foreach ($datos as $num)
//while($num=mysqli_fetch_array($resultado))
{
echo var_dump($num);
echo "<tr>
<td>".$num['titulo']."</td>
<td>".$num['subtitulo']."</td>
<td>".$num['resumen']."</td>
<td>".$num['noticias']."</td>
<td>".$num['imagen']."</td>
</tr>";
} ?>
</table>
</body>
</html>
Valora esta pregunta


0