Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Fetch Data From Database With PDO

$host = 'localhost'; // URL to the server
$username = 'root'; // Username (xampp = root)
$password = ''; // Password (xampp = )
$dbname = 'apifile';
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$sql = "SELECT * FROM `prop` WHERE propkey='localhost_100100'";

$q = $pdo->query($sql);

$q->setFetchMode(PDO::FETCH_ASSOC);
$r = $q->fetch();
var_dump($r['propvalue']);
 
PREVIOUS NEXT
Tagged: #Fetch #Data #From #Database #With #PDO
ADD COMMENT
Topic
Name
2+4 =