Skip to content

Instantly share code, notes, and snippets.

@arif98741
Created March 26, 2018 17:03
Show Gist options
  • Save arif98741/04956df8055459fa06fcb2c348e0ff60 to your computer and use it in GitHub Desktop.
Save arif98741/04956df8055459fa06fcb2c348e0ff60 to your computer and use it in GitHub Desktop.
Get Data by id
<?php
$con = new mysqli("localhost", "root", "password", "database");
if($con)
{
$id = "123";
$sql = "select * from table where id='$id'";
$stmt = $con->query($sql);
if($stmt)
{
if($stmt->num_rows>0)
{
$value = $stmt->fetch_assoc();
//$value = $stmt->fetch_object();
echo "Hellow ".$value['name'];
echo "Username ".$value['username'];
echo "Email ".$value['email'];
//regards www.phpdark.com
}else{
echo "No Data Found";
}
}
}else{
echo "Failed To connect database"
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment