Tuesday 7 July 2020

Get single row from MYSQL | PHP

Get a single row for editing or another purpose from MySql using PHP.



$conn=mysqli_connect("localhost","root","","girfadb");
$sql="select   name, phone  FROM  stu where  id=101";
$row=$conn->query($sql)->fetch_assoc() or die("<h1>Error</h1>". mysqli_error($conn));
echo $row['name'];
echo $row['phone'];
mysqli_close($conn);

No comments:

Post a Comment