Skip to content

Instantly share code, notes, and snippets.

@DDOrozco17
Last active October 20, 2023 17:56
Show Gist options
  • Save DDOrozco17/b4af570eb27705640166be836f623fe8 to your computer and use it in GitHub Desktop.
Save DDOrozco17/b4af570eb27705640166be836f623fe8 to your computer and use it in GitHub Desktop.
Act 7 bd
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php
$servidormysql = "localhost";
$usuariosql = "root";
$pass = "";
$dbnombre = "bdpapeleria";
// Create connection
$conpaeleria = new mysqli($servidormysql, $usuariosql, $pass, $dbnombre);
// Check connection
if ($conpaeleria->connect_error) {
die("Connection failed: " . $conpaeleria->connect_error);
}
$sql = "SELECT id, nProducto, catProducto, pUnitario FROM tbl_productos";
$resultado = $conpaeleria->query($sql);
echo "<h1>Tabla Productos</h1>";
if ($resultado->num_rows > 0) {
// output data of each row
while ($row = $resultado->fetch_assoc()) {
echo "id: " . $row["id"] . " - Nombre Producto: " . $row["nProducto"] . " -Categoria Producto: " . $row["catProducto"] . " -Precio Unitario " . $row["pUnitario"] . "<br><br>";
}
} else {
echo "0 results";
}
$conpaeleria->close();
?>
</body>
</html>
@DDOrozco17
Copy link
Author

image

@DDOrozco17
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment