Jump to content

Percent Bars for a web poll


coolgamer48

Recommended Posts

Try this:<div style="width: 200px"><?php echo "<div style=\"width: " . $percent . "%; background-color: blue; height: 5px;\"></div>"; ?></div>Change the variable $percent for whatever variable has the number you wanted.

Link to comment
Share on other sites

Thanks - it worked great.BTW, what's \" used for exactly? I used ' and it worked fine.
It is called escaping (using \ to characters such as ", ', \). In this case, you would need to use \" because if you didn't have \ before ", PHP would think you are ending the string, using ' and " as a way to say something is a string, and trying to use PHP code like a variable, function, etc. This would make an error because you didn't use string concatenation (adding strings with .) and PHP doesn't know what width: is. This is just a way to output those special characters.
Link to comment
Share on other sites

Many control characters can be represented using escaped letters, such as \t for tab and \r for carriage return.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...