PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Sep 27, 2020 9:30 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Jun 28, 2015 12:55 am 
Offline
Forum Newbie

Joined: Sun Jun 28, 2015 12:52 am
Posts: 3
I have a doubt regarding this script
This is defined about a progress bar

public function progressBarStatus($number)
{
return ($number == 0) ? lang('NOTSTARTED') : '<div class="progress-bar ui-progressbar ui-widget ui-widget-content"><div class="inner-orange ui-corner-left" style="width:' . $number . '%;">' . $number . '%&nbsp;&nbsp;</div></div>';
}

See I want the progress bar to have orange colour only when score is below 70%

The code for determining score is

<td><?php echo $row->score;?>% <?php echo $content->progressBarStatus(intval($row->marks/$row->fullmarks*100));?> (<?php echo intval($row->marks);?>/<?php echo intval($row->fullmarks);?>)</td>

What changes should I make?

Now what's happening by default it is showing orange colour for all scores. The other colour is green what I want its there in lib.php. Just tell me How I should reframe the other code like using if else or something


Top
 Profile  
 
PostPosted: Sun Jun 28, 2015 2:20 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
Use an if statement to define the color for <70% and >=70%. Then use that color in the HTML.
Syntax: [ Download ] [ Hide ]
public function progressBarStatus($number)
{
        if ($number < 70) {
                $color = 'orange';
        } else {
                $color = 'green';
        }
        return ($number == 0) ? lang('NOTSTARTED') : '<div class="progress-bar ui-progressbar ui-widget ui-widget-content"><div class="inner-' . $color . ' ui-corner-left" style="width:' . $number . '%;">' . $number . '%&nbsp;&nbsp;</div></div>';
}


Top
 Profile  
 
PostPosted: Mon Jun 29, 2015 9:43 am 
Offline
Forum Newbie

Joined: Sun Jun 28, 2015 12:52 am
Posts: 3
thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group