Home > Back-end >  How to fetch data from Database using prepare and bind?
How to fetch data from Database using prepare and bind?

Time:03-25

I'm trying to fetch my Data from Database using PHP prepare and bind statement but I don't understand where I'm doing wrong? I uses Stackoverflow answers to find a solution but it isn't work for me.

Here is my Code

<?php
$host='localhost';
$name='root';
$pass='';
$db='prepare_bind';
$conn=mysqli_connect($host,$name,$pass,$db);

$ge_data=$conn->prepare("SELECT * FROM Learn_prepare_bind");
$ge_data->execute();

$result=$ge_data->get_result(); 
if($result->num_rows == 1){
    while($row=$result->fetch_assoc()){
        echo $row['u_name'];
    }
}

?>

Anyone help me out? where I'm wrong

Thank you!

I'm trying to fetch Data but it showing blank white page.

CodePudding user response:

Try

<?php
...
if($result->num_rows >= 1){
....

?>
  • Related