I am creating a database fetch application and this is for test. All works fine but it fails to retrieve auto increment id from database. It says 'Undefined index id' if not defined id as null so i tried id = null but that shows nothing. My database has: email, password, id(AI, unique). What should i do to fetch id?
Code:
$email = "test@yahoo.com";
$password = "test";
$conn = mysqli_connect('localhost', 'root', '', 'users_database');
$query = "SELECT email, password FROM users_main_info WHERE email = '$email'";
$query_run = mysqli_query($conn, $query);
$em = null;
$pa = null;
$id = null;
while($row = mysqli_fetch_assoc($query_run)){
$id = $row['id'];
$em = $row['email'];
$pa = $row['password'];
}
echo $id;