I'm currently trying to create a function where I can control what field and what values get pulled. This is something I had in mind, but it doesn't work. I get no error, it returns an empty array.
public function test ($field, $id) {
$sql = $this->con->prepare("SELECT ? FROM Content WHERE id=?");
$sql->bindParam(1, $field);
$sql->bindParam(2, $id);
$sql->execute();
while ($row = $sql->fetch()) {
echo $row;
}
}
I'm unsure about the "SELECT ?..." part I'm not 100% sure that is the correct way. The basic idea is I can make a call anywhere like:
< ?php $obj = new handler; $obj->test($_GET['Title'], $_GET['id']); ?>
which will echo the Title with the correct id.