My suggestion would be to use mysqli
functionality as such:
<?php
$mysqliClass = mysqli_init();
$mysqliClass->real_connect("hostname or IP", "dbUsername", "dbPassword", "databasename");
$query = "SELECT `username` AS display_name, `fullname` AS full_name, `email`, `role` as administrators, `status` as be_on FROM `admin`";
$rs = $mysqliClass->query($query); # Preform your query
$showUser = false; # Start negative
$row = []; # Set a variable for the row to go into
while ($result = mysqli_fetch_assoc($rs)) # Fetch each result one at a time
{
if ($result['administrators'] == 1) # Check the role
{
$showUser = true; # Set the show to true if it equals 1
$row = $result; # Set the row to equal the result given
}
break; # You only need the first result
}
if ($showUser)
{
/* Do your work with $row! */
}
?>
I have also removed email AS email
for just email
as it will already have this name so it is unrequired mess.
I would also recommend adding a WHERE
clause in your query to reduce (filter) the results
If you are using an image from your DB, you could do something such as this:
<img src="<?=$row['image_column_name'];?>" height="120" width="120" />
And this should show the image as you want it to :)
Source of example code
Fuller example like the original answer:
<?php
$mysqliClass = mysqli_init();
$mysqliClass->real_connect("hostname or IP", "dbUsername", "dbPassword", "databasename");
$query = "SELECT `name`, `logo` AS describe , IF(`status` = 0, 'Online', 'Offline') as be_on FROM `domain`";
$rs = $mysqliClass->query($query);
$rows = []; # This will have more than one in it this time!
while ($result = mysqli_fetch_assoc($rs))
{
$rows[] = $result;
}
foreach ($rows as $r)
{
foreach ($r as $rowKey => $rowValue) # Double loop because you have an array in an array this way
{
if ($rowKey == "describe")
{
print '<img src="' . $rowValue . '" height="120" width="120" />';
}
}
}
?>