I have a table:
Scenario: Here you will see 5 badges (badge1
till badge5
). When an employee is rewarded a badge it becomes 1
, else 0
. For example: Brinda wins all the badges, whereas lyka wins only badge1
.
Badges are stored as blob images in a different badgePhoto
table:
UI to display the badge:
Now, I have a UI where I want to display the recent 3 badges won.
- If 1 badge is won, only 1 will be shown.
- If 5 badges is won random 3 badges will be shown.
- If no badges is won then echo "no badges won".
HTML related to the badge in the above UI :
<div class="panel">
<div class="form" style="width: 350px; height: 220px;">
<div class="login">Recent badges</div>
<span class="fa-stack fa-5x has-badge">
<div class="badgesize">
<img src="images/7.png" alt="" >
</div>
</span>
<span class="fa-stack fa-5x has-badge">
<div class="badgesize">
<img src="images/1.png" alt="" >
</div>
</span>
<span class="fa-stack fa-5x has-badge">
<div class="badgesize">
<img src="images/2.png" alt="" >
<!-- <img class="cbImage" src="images/7.png" alt="" style="width:50px;height:50px"/> -->
</div>
</span>
</div>
</div>
<!-- badges panel ends here -->
The image tags tells about the badges.
I have some PHP to fetch the data:
$q2 = "SELECT * FROM pointsBadgeTable WHERE EmployeeID = '" . $_SESSION['id'] . "' ";
$stmt1 = sqlsrv_query($conn,$q2);
if ($stmt1 == false)
{
echo 'error to retrieve info !! <br/>';
die(print_r(sqlsrv_errors(),TRUE));
}
$pbrow = sqlsrv_fetch_array($stmt1);
Then I will echo the image of a badge from the table if the condion suffice i.e if the count for that badge has a value of 1. I will echo it in the above html code.
<?php echo "" . $pbrow['badge1/badge2/...'] . "" ?>
What I am trying to do here is similar to the profile in Stack Overflow. Here under newest, you can see a "critic" badge. How can we bring a newest badge or any badge according to a condition?