I have the following code and trying to implement a for loop to display a font awesome sticker on the page if the student has practice his or her piano but the sticker is going in a random direction and not in a straight line as shown below:
I can get my point system now to work but the stickers are still not lining up correctly…Could it be a CSS issue? how would I do this to line it up if my class is fas?
I have changed the color however by doing this… I have used display: inline-block but the first star is not correctly shown…
.star1 {
display: inline-block;
color:blue;
}
It now looks like this but the first sticker is still way off
It is working fine and if I insert a new record, a star will appear but how would I reset the counter once the user has 10 stars? I tried to do this after the code but it just keep looping…
Thanks… What is the difference between a for loop and a do while loop? I understand the code and the process but how would we know when to use either of them?
The breaks work but for some reason, the sticker is not appearing again. I am assuming that the counter is not reset to 0…
I decided to give a random picture instead but how come the following code does not work with my points system? If i used $resultCheck instead of $x, then it doesn’t work but if I changed it back to $x, then it does work…
for ($x = 1; $x <= $resultCheck; $x++) {
if ($x == $increment) {
$increment += 5;
$points += 100;
$sql = "UPDATE rewards
Set reward_points = ?
WHERE user_uid = ?
";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
echo 'SQL error';
} else {
mysqli_stmt_bind_param($stmt, "is", $points, $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
}
}
}
but if I do this, then it does not work:
for ($x = 1; $x <= $resultCheck; $x++) {
if ($resultCheck == $increment) {
$increment += 5;
$points += 100;
$sql = "UPDATE rewards
Set reward_points = ?
WHERE user_uid = ?
";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
echo 'SQL error';
} else {
mysqli_stmt_bind_param($stmt, "is", $points, $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
}
}
}
I can get my point system now to work but the stickers are still not lining up correctly…Could it be a CSS issue? how would I do this to line it up if my class is fas?
I have changed the color however by doing this… I have used display: inline-block but the first star is not correctly shown…
.star1 {
display: inline-block;
color:blue;
}
It now looks like this but the first sticker is still way off