Jump to content


Photo

Image Resize


  • Please log in to reply
2 replies to this topic

#1 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 09 March 2006 - 06:18 PM

Hello again people,

I've set up a HTML (which includes PHP coding). On the page I have a section called progress which retrieves data from mySQL and displays a percentage as to a users progress.

I was wondering if I could also do this graphically using PHP by having a simple bar image (bar.png) that expands depending upon the percentage.

As the image is a pixel or so wide I was hoping that I could simply change the width of the .png image using PHP code, setting the width to the percentage [ie 50% would make the bar width 50 pixels wide or something like that]

(Hope I said that right - something like all those online games you see with health bars etc)


Thanks in advance

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 09 March 2006 - 06:25 PM

Like this, perhaps?
<?php
$pct = 50; // percent complete retrieved 'somehow' 
?>
<img src="bar.png" height="10" width="<?php echo $pct;?>" alt=""/>

Legend has it that reading the manual never killed anyone.
My site

#3 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 09 March 2006 - 06:32 PM

It works!

Thanks for the help, cant believe it was something so simple - so simple I overlooked it lol




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users