I'm trying to get all the $title
from a mysql table called pages
.
But I do not understand why I can only get the last one using my code bellow:
if( ! $stmt = $db_conx->prepare("SELECT id, title FROM pages") ) {
die( $db_conx->error );
}
$stmt->bind_param('i', $id);
if ( ! $stmt->execute() ) {
die( $stmt->error );
}
$stmt->bind_result($id, $title);
$stmt->store_result();
while($stmt->fetch()) {
$value[] = array('id'=>$id, 'title'=>$title);
}
echo $title;
is there anything missing from my code?
I'm absolutely baffled with this. any help would be appreciated.