11-22-2016, 03:43 AM
Well I'm making a bunch of progress, and am working on the logic now for it (to avoid clicking the same function more than once) and I am comfortable on figure that out tomorrow...but my OCD is getting to me again on another piece.
So I'm just trying to set a condition that changes some verbiage depending on how many results are returned. I have it half ass working, just not fully...
As of right now, if it finds no results, I get - "There is 0 person on break right now." <----- This bothers me. I just want it to say "There is no one on break right now."
If there's one person on break, I get - "There is 1 person on break right now.
Shawn"
If there's more than one person on break, I get - "There are 2 people on break right now.
Shawn
test"
I know I'm derping this up somewhere simple, but every form of >,<,<=,=>,== I try with any number just keeps failing. It'll fix one os the issues, then break another lol.
$breaksQ = $db->query("SELECT * FROM users WHERE on_break = 1");
$breaks = $breaksQ->results();
$countbreaks = $breaksQ->count();
if ($countbreaks <= 1) {
?>
<h3>There is <?=$countbreaks?> person on break right now.</h3>
<? foreach ($breaks as $b){
echo $b->fname;
echo "<br>";
}
}
elseif ($countbreaks >= 2) {
?>
<h3>There are <?=$countbreaks?> people on break right now.</h3>
<? foreach ($breaks as $b) {
echo $b->fname;
echo "<br>";
}
}
else {
echo "<h3>There is no one on break right now.</h3>";
So I'm just trying to set a condition that changes some verbiage depending on how many results are returned. I have it half ass working, just not fully...
As of right now, if it finds no results, I get - "There is 0 person on break right now." <----- This bothers me. I just want it to say "There is no one on break right now."
If there's one person on break, I get - "There is 1 person on break right now.
Shawn"
If there's more than one person on break, I get - "There are 2 people on break right now.
Shawn
test"
I know I'm derping this up somewhere simple, but every form of >,<,<=,=>,== I try with any number just keeps failing. It'll fix one os the issues, then break another lol.
$breaksQ = $db->query("SELECT * FROM users WHERE on_break = 1");
$breaks = $breaksQ->results();
$countbreaks = $breaksQ->count();
if ($countbreaks <= 1) {
?>
<h3>There is <?=$countbreaks?> person on break right now.</h3>
<? foreach ($breaks as $b){
echo $b->fname;
echo "<br>";
}
}
elseif ($countbreaks >= 2) {
?>
<h3>There are <?=$countbreaks?> people on break right now.</h3>
<? foreach ($breaks as $b) {
echo $b->fname;
echo "<br>";
}
}
else {
echo "<h3>There is no one on break right now.</h3>";