I have a php script with me. I have a doubt on a few lines of script regarding progre

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webbiesindia
    New Member
    • Jun 2015
    • 1

    I have a php script with me. I have a doubt on a few lines of script regarding progre

    I have a doubt regarding this script
    This is defined about a progress bar

    Code:
    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 . '%**</div></div>';
    	  }
    See I want the progress bar to have orange colour only when score is below 70%

    The code for determining score is

    Code:
    <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
    Last edited by Rabbit; Jun 28 '15, 04:17 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • computerfox
    Contributor
    • Mar 2010
    • 276

    #2
    1) I want to point out that this is not a "script" because you have HTML objects. A script is something that simply runs the instructions you build into it. For example, a shell script.

    2) I don't see any conditional statements (if, else if, else) so it's not checking for your requirements

    3) I would suggest starting by cleaning up your code
    a. Line up the brackets with the function name or bring the first bracket up to the same
    line. No use in wasting a new line for just a bracket.
    b. The function only has one really long line that it returns. Break down the return
    statement
    c. The HTML should be broken into new lines. The td's should be separate lines

    Comment

    Working...