How can I retrieve and display data from mysql database using php PDO ?
Here is my code. I know how to do it using mysql_ function .
This is what I tried but it displays nothing so far .
#query to display the users
$select_all=("select * from tish_user
inner join tish_clientinfor on tish_user.user_id = tish_clientinfor.user_id
inner join tish_images on tish_user.user_id = tish_images.user_id
inner join tish_security on tish_user.user_id = tish_security.user_id");
$result = $con->query($select_all);
#if the statement is success full
if($result !== false ){
$cols = $result->columnCount();
#echo number of rows
echo 'num rows'.$cols.'</br>';
#pass the result set
foreach($result as $row){
echo $row['username'].'</br>';
}
}
?>
After the prepare, you need to execute.
Like this:
After that, loop through results:
You can additionally give
PDO::FETCH_ASSOCto the fetch statement for the associative results.