i'm making a small account using login, now i have to display name from ID who is logged in. suppose, i have two accounts into my database now as i print his name, it shows ID no. 1's name while i'm logged in using ID no. 2 can you tell me what's going on? where i'm suppose to be wrong?,
here is my change_setting_db.php :
<?php
$con=mysqli_connect("localhost","root","Bhawanku","members");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM admin");
?>
and here is my general_setting.php :
<div id="change_name">
<label><strong>Name: </strong></label>
<?php
include('change_setting_db.php');
while($row = mysqli_fetch_array($result))
{
echo $row['first_name']." ".$row['last_name'];
}
?>
<a id="display_float" href="change_name.php">Edit</a>
</div><hr>
EDITED
i tried but it's not working..
<?php
$con=mysqli_connect("localhost","root","Bhawanku","members");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM admin");
if ($row = mysqli_fetch_array($result)) {
$id=$row['id'];
mysqli_query($con,"SELECT * FROM admin WHERE id='$id' ");
}
?>