Como hacer varios msqli_fetch_array()
Publicado por Marvin (21 intervenciones) el 26/10/2017 01:58:19
Hola, estoy en un dilema, quisiera que por favor me ayuden guiandome sobre como hacer varios msqli_fetch_array() para mostrar resultados de varias filas de una tabla en un HTML.
//index.php
Podrian ayudarme , es muy confuso esto de mezclar HTML con PHP
//index.php
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
<?php
//Crear Variables para conexion Noticias Principales
$host = "localhost";
$user = "kautivai_EditorDeNoticias";
$pw = "****************";
$dataBase1 = "kautivai_DatosDeNoticias";
$conexion = mysqli_connect($host, $user, $pw, $dataBase1) or die("Problemas al conectar con base de datos 'kautivai_DatosDeNoticias'");
// Ejecutamos las consulta
$result = mysqli_query($conexion, "SELECT * FROM Noticia1 WHERE ID = '1'") or die("Error al realizar consulta: ".mysqli_error($conexion));
while($final = mysqli_fetch_array($result)){ //apertura de primer while
<html>
<head>
</head>
<body>
<div id="Seccion1">
<h1>Hay bastante codigo html, es una pagina completa, no solo esta compuesta por h1</h1>
<h1><?php echo $final['Texto1']; ?></h1>
<h1><?php echo $final['Texto2']; ?></h1>
</div>
<?php
} //Cierre primer while
?>
<?php
$result2 = mysqli_query($conexion, "SELECT * FROM Noticia1 WHERE ID = '2'") or die("Error al realizar consulta: ".mysqli_error($conexion));
while($final2 = mysqli_fetch_array($result2)){ //apertura de segundo while
<div id="Seccion2">
<h1><?php echo $final2['Texto3']; ?></h1>
<h1><?php echo $final2['Texto4']; ?></h1>
</div>
<?php
} //Cierre de segundo while
?>
</body>
</html>
?>
Podrian ayudarme , es muy confuso esto de mezclar HTML con PHP
Valora esta pregunta


0