Tabla dinamica
Publicado por Brouse_13 (6 intervenciones) el 24/12/2018 13:16:47
Buenas tengo una cunsulta, hice una tabla dinamica pero me da un error y no se detectarlo. Me podriais ayudar?
index.php
db_connect.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
<html>
<head>
</head>
<body>
<?php
include "db_connect.php"
$sql = "SELECT id, usuario, motivo, hora, descripcion FROM sanciones";
$result = $conn->mysqli_query($sql);
?>
<table id="tabla_dinamica" class="w3-table">
<tr>
<th>Id</th>
<th>Usuario</th>
<th>Hora</th>
<th>Motivo</th>
<th>Descripcion</th>
<?php
if ($result->num_rows > 0) {
// Introducir datos en tabla
while($row = $result->fetch_assoc()) {
echo "<tr id="$row["id"]">";
echo "<td>" . $row["id"] "</td>";
echo "<td>" . $row["usuario"] "</td>";
echo "<td>" . $row["hora"] "</td>";
echo "<td>" . $row["motivo"] "</td>";
echo "<td>" . $row["descripcion"] "</td>";
}
echo "</table>";
} else {
echo "no hay tablas creadas"
}
?>
db_connect.php
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
Valora esta pregunta


0