Re: Load PHP page via database ID
Posted: Sat Aug 24, 2013 7:50 am
Looks like you're stuck using MySQLi, then. Unfortunate, but not the end of the world. The code in my previous example would become:
Code: Select all
<?php
$sql = new mysqli('localhost', 'username', 'password', 'database_name');
if (isset($_GET['id'])) {
$query = "SELECT name, username, content FROM pages WHERE id = ?";
$stmt = $sql->prepare($query);
$stmt->bind_param('i', $_GET['id']);
$stmt->execute();
$stmt->bind_result($name, $username, $content);
$stmt->fetch();
}