PDA

View Full Version : Help with a progress widget please.


B16MCC
03-07-2012, 01:56 PM
Hi guys, I'm looking to build a widget either HTML or PHP to display progress.

Let's say I set a target of ?1000. Perhaps I add this to the database or more simply just use a text file on my server. I read the single line of text from the text file which is my current value. I want to display that value as a progress bar.

For example,

progress bar min value = 0
progress bar max value = 1000

Read value from file, EG, 125
Show this value on the progress bar.

Secondly, I want a button that opens an input box where I enter a value, and it adds that value to the value stored in the text file then updates the progress bar.

I've got some PHP code for reading and writing to a text file , but I've not idea where to start with a progress bar and input box.

Here's what I've got so far, simply displaying the value from the file.

$file = "martin_fund.txt";
$f = fopen($file, "r");
while ( $line = fgets($f, 4) ) {
$output = '?' . $line;
}

Any help would be greatly appreciated.
Thanks
B.

kh99
03-07-2012, 08:11 PM
You could of course do what you described. I think the easiest thing would be to add an option in the admincp to set the max and current value, and you wouldn't need to read or write a file (but of course that would mean logging in to the admincp to change the value). As for drawing the bar, I think there are a number of progress bar mods that you could look at, and I'm sure if you googled progress bar you'd find the html for just about any look you wanted. I remember looking at on that was just an image that get's stretched based on the percentage, so it was all done with html.