Q:

get ID for a specific user in mysql database in PHP

When a user signs in i want to echo back there ID (which is created because of the auto_increment in phpMyAdmin) from there account, here's my login.PHP:
<?php

$conn = mysqli_connect("xxxxxx", "xxxxx", "xxxx", "BuyerAccounts");

$Email = $_POST["Email"];
$Password = $_POST["Password"];

$sql_query = "select Buyer_Email from user_info where Buyer_Email like '$Email' and Buyer_Password like '$Password';";

$result = mysqli_query($conn, $sql_query);

if(mysqli_num_rows($result) > 0 ){

$row = mysqli_fetch_assoc($result);
$name = $row["Buyer_Email"]; 
echo "Welcome: Buyer";

}else{
$int = 1;
//echo "Buyer login failed...";
}
}else{
echo "Login failed...";
}
}

mysqli_stmt_close($statement);

mysqli_close($conn);

?>

A:

Add the column name id in your sql query.let say your column name for id is ID
$sql_query = "select ID,Buyer_Email from user_info where Buyer_Email like '$Email' and Buyer_Password like '$Password';";
$result = mysqli_query($conn, $sql_query);

if(mysqli_num_rows($result) > 0 ){

$row = mysqli_fetch_assoc($result);
$name = $row["Buyer_Email"]; 
$user_id =  $row['ID'];
echo $user_id;
echo "Welcome: Buyer";

}

Since your making login in php its good choice to use $_SESSION.
All you need to do is add a session_start(); at the top of any php script where you need to use session.
<?php
session_start();
$conn = mysqli_connect("xxxxxx", "xxxxx", "xxxx", "BuyerAccounts");

$Email = $_POST["Email"];
$Password = $_POST["Password"];
 $sql_query = "select ID,Buyer_Email from user_info where Buyer_Email like '$Email' and Buyer_Password like '$Password';";

    $result = mysqli_query($conn, $sql_query);

    if(mysqli_num_rows($result) > 0 ){

    $row = mysqli_fetch_assoc($result);
    $name = $row["Buyer_Email"]; 
    $user_id =  $row['ID'];

    //using session
    $_SESSION["user_id"] = $user_id;

    echo $user_id;
    echo "Welcome: Buyer";

    }

Now you can access anywhere in your php script using the $_SESSION variable.
echo $_SESSION["user_id"] ;

