Created
January 17, 2018 16:44
-
-
Save telefonosuci/6866cdb664a4bea125584ba48d2b156f to your computer and use it in GitHub Desktop.
PHP MySQL connection and select
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Create connection | |
$conn = new mysqli("localhost", "root", ""); | |
// Check connection | |
if ($conn->connect_error) { | |
die("Connection failed: " . $conn->connect_error); | |
} | |
echo "Connected successfully"; | |
mysqli_select_db($conn,"dbtest"); | |
$sql = "SELECT * from indovina_numero"; | |
$result = $conn->query($sql); | |
$A= array(); | |
$B= array(); | |
$C= array(); | |
$D= array(); | |
$E= array(); | |
if ($result->num_rows > 0) { | |
// output data of each row | |
$i=0; | |
while($row = $result->fetch_assoc()) { | |
echo "A: " . $row["A"]. " B: " . $row["B"]. " C:" . $row["C"]. " D: ".$row["D"]." E: ".$row["E"]."<br>"; | |
$i++; | |
} | |
} else { | |
echo "0 results"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment