Created
September 11, 2018 12:00
-
-
Save dandyraka/3bf72ab59c3580b848001779148821f1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
include('koneksi.php'); | |
$query = 'SELECT nama, email FROM member WHERE id = ?'; | |
$id = 1; | |
if($stmt = $mysqli->prepare($query)){ | |
/* | |
Binds variables to prepared statement | |
i corresponding variable has type integer | |
d corresponding variable has type double | |
s corresponding variable has type string | |
b corresponding variable is a blob and will be sent in packets | |
*/ | |
$stmt->bind_param('i',$id); | |
/* execute query */ | |
$stmt->execute(); | |
/* Store the result (to get properties) */ | |
$stmt->store_result(); | |
/* Get the number of rows */ | |
$num_of_rows = $stmt->num_rows; | |
/* Bind the result to variables */ | |
$stmt->bind_result($nama, $email); | |
while ($stmt->fetch()) { | |
echo 'Name: '.$nama.'<br>'; | |
echo 'Email: '.$email.'<br><br>'; | |
} | |
/* free results */ | |
$stmt->free_result(); | |
/* close statement */ | |
$stmt->close(); | |
} | |
/* close connection */ | |
$mysqli->close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment