php - Returning Multiple Data with MySQL query -
there couple questions have regarding following code:
// create new mysql connection, inserting host, username, passord, , database connecting $conn = new mysqli('xxx', 'xxx', 'xxx',); if(!$conn) { die('connection failed: ' . $conn->error()); } // create , execute mysql query $sql = "select artist_name artists"; $result = $conn->query($sql); // loop through returned data , output while($row = $result->fetch_assoc()) { printf( "artist: %s<br />", $row['artist_name'], "<br />", "profile: %s<br />", $row['artist_dob'], "<br />", "date of birth: %s<br />", $row['artist_profile'], "<br />", "password: %s<br />", $row['artist_password'], "<br />" ); } // free memory associated query $result->close(); // close connection $conn->close();
how can assign artist_dob
, artist_profile
, , artist_password
, return browser?
what statement $conn->error()
mean? don't understand ->
sign does.
the printf()
function return information screen. $conn->error() echo out database error if there 1 trying connect. ->
means it's calling function object $conn
object , has lots of functions , $conn->query()
means run query function on $conn
object.
you may want beginner php object-oriented tutorials: https://www.google.com/search?q=beginner+guide+to+php+oop
Comments
Post a Comment