Skip to content

Instantly share code, notes, and snippets.

@abimaelmartell
Created January 28, 2021 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abimaelmartell/2fd22becffe85b59ae8b6714a05df023 to your computer and use it in GitHub Desktop.
Save abimaelmartell/2fd22becffe85b59ae8b6714a05df023 to your computer and use it in GitHub Desktop.
Ejemplo de Espaghetti
<?php
$servername = "127.0.0.1";
$username = "user";
$password = "password";
$dbname = "db";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM `posts`";
$result = $conn->query($sql);
echo "Retrieving ". $result->num_rows ." rows\n";
while ($row = $result->fetch_assoc()) {
echo "Post {$row['id']} is {$row['status']}";
}
$conn->close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment