Created
September 19, 2017 09:37
-
-
Save asathoor/212763e3a1683443f571ffc96f28de79 to your computer and use it in GitHub Desktop.
Mysql_cnt1
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 | |
// CONNECT TO THE SAKILA DATABASE | |
$mysqli = new mysqli( | |
"localhost", | |
"root", | |
"mojndo", | |
"forta_cnt1" | |
); // creates the object | |
if ($mysqli->connect_errno) { | |
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " | |
. $mysqli->connect_error; // if error messages | |
} | |
/* test your connection */ | |
echo "Your're connected to the database via: " | |
. $mysqli->host_info | |
. "\n"; | |
$sql = "SELECT * FROM `customers` ORDER BY `cust_name` DESC"; | |
$result = $mysqli->query($sql); // query | |
?> | |
<h2>Kunder</h2> | |
<?php | |
// looping out the result | |
while($row = $result->fetch_assoc()){ | |
echo $row['cust_name'] . " -- "; | |
} | |
mysqli_close($mysqli); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment