Last active
August 29, 2015 14:15
-
-
Save bluejaysql/0803355bd98568e6ec6d to your computer and use it in GitHub Desktop.
Connecting PHP to basic Justice League MySQL db
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 | |
define ('dbuser', 'root'); | |
define ('dbpassword', 'password'); | |
define ('dbhost', 'localhost'); | |
define ('dbname', 'jl'); | |
$dbcon = @mysqli_connect (dbhost, dbuser, dbpassword, dbname) OR die ('Could not connect to MySQL: ' . mysqli_connect_error () ); | |
mysqli_set_charset($dbcon, 'utf8'); | |
$result = mysqli_query($dbcon, "SELECT justiceleaguer.alias, justiceleaguer.alterego, species.name FROM justiceleaguer LEFT JOIN species ON justiceleaguer.species = species.id ORDER BY justiceleaguer.id;"); | |
while($row = mysqli_fetch_array($result)) { | |
echo $row['alias'] . " is " . $row['alterego'] . ", a " . $row['name'] . ". <br>"; | |
} | |
mysqli_close($dbcon); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment