Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9000995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:22:44+00:00 2026-06-16T00:22:44+00:00

I have a projectstatus in my mysql database. Depending on the status, it’s 1,

  • 0

I have a projectstatus in my mysql database. Depending on the status, it’s 1, 2 or 3. Also I have a css status bar of which I can set the width of, to see the progress.

Here’s the example code:

<td>" . $projstatid ."
    <div class='meter-wrap'>
        <div class='meter-value' style='background-color: #0a0; width: 33,3%;'>
            <div class='meter-text'></div>
            </div>
    </div>
</td>

Now I can do 3 if statements at the width’s size like:

if ($projstatid) = 1 { echo "33.3%"; } elseif {..} else {...}

But how do I write a simple loop which loops through the numbers untill it reaches the $projstatid‘s value, but every time it re-loops adds 33.3%?

Even better would be if the loop devided the amount time of loopings by the max amount of projstatids. But that I’ll figure out, once I have this basic loop working.

EDIT

What I’m trying to do is to create a loop which does this:

x=1
y=0
$projectstatid = $record['projectstatid'] (in this example lets say it's 5)

loop: x=1, is it 5? Nope. return: y= +20%
loop: x=2, is it 5? Nope. return: y= +20%
etc.

untill it reaches 5 (and it will return 100%)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:22:45+00:00Added an answer on June 16, 2026 at 12:22 am

    You can do something like this to compute the percent corresponding to your current value :

    $percent = floor($number * 100 / $nbmax);
    

    Here $percent is the value to put in your css and $number is your current status and $nbmax is the maximum value that it could have.

    In your case your would have :

    $number  = $record['projstatid'];
    $nbmax = 3;
    $percent = floor($number * 100 / $nbmax);
    

    EDIT: Based on your edit I guess you want something like this:

    $number = 5;
    for($i = 1 ; $i < $number; $i++) {
        $percent = floor($i * 100 / $number);
        echo $percent;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem. I am trying to check to see if status's
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have deployed numerous report parts which reference the same view however one of them
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
Have two tables say ABC and XYZ and contain one column which data will
Have a photography site that I want to prevent image copying from. How can
Have created a ATL COM project through which I am inserting Menu Items to
I have a complex, 3NF database being provided to me for a particular project.
In a Rails 3.2 app I have a model Project, which has many Tasks.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.