How to create a progress bar showing number of calories user has left to burn?

I’m making a calories burned calculator which links to goals the user has made.

I want to create a progress bar that updates when the user clicks a button that shows how many calories the user has yet to burn in order for them to reach their goal.

I’ve stored the amount of calories burned for each activity the user input.
The users goals are set in either lbs or kg, so I’m not sure how I can set a value for these units. :confused:

Also, I’m not sure how I should calculate the calories left to burn.

I’ve looked online, however can’t find anything that relates to how to made a progress bar with data from an sql database.

Database: ‘registration’ Table: ‘tracklog’ and ‘goal’

There is now an html <progress> element for displaying a progress bar:-

That would seem the natural choice for this. It has attributes for the total value (goal) and the current progress value.
These values could easily be echoed out by php.

I’m no dietitian or fitness expert, so don’t know how calories burnt relate to weight, this maybe is not the best place to find that formula. But I’m sure the arithmetic functions within php would be capable of doing the calculations once you know the formula.
Pulling data from sql and using in html is fairly standard stuff and should be achievable knowing the specifics of the data.

1 Like

Thanks for your answer!
The values I want for each weight unit are:
3700 calories = 1lb
7700 calories = 1kg

Do you know how I can set these?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.