coolgamer48 Posted December 14, 2007 Share Posted December 14, 2007 HeyDoes anyone have any ideas on how I can show bars representing the various choices in a web poll? I already have the percent values, I just can't think of how to make bars to represent them.Please and thank you! Link to comment Share on other sites More sharing options...
Ingolme Posted December 15, 2007 Share Posted December 15, 2007 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 More sharing options...
coolgamer48 Posted December 15, 2007 Author Share Posted December 15, 2007 Thanks - it worked great.BTW, what's \" used for exactly? I used ' and it worked fine. Link to comment Share on other sites More sharing options...
Ingolme Posted December 15, 2007 Share Posted December 15, 2007 It's just a habit of mine. Both of them are the same. Link to comment Share on other sites More sharing options...
zppblood Posted December 16, 2007 Share Posted December 16, 2007 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 More sharing options...
Synook Posted December 16, 2007 Share Posted December 16, 2007 And to be XHTML valid you have to use " for attribute values. Link to comment Share on other sites More sharing options...
coolgamer48 Posted December 16, 2007 Author Share Posted December 16, 2007 Ohh... okay - so \" just outputs a " character, like \n outputs a new line. Link to comment Share on other sites More sharing options...
zppblood Posted December 17, 2007 Share Posted December 17, 2007 Exactly, they will both return those results when using " for your strings. Link to comment Share on other sites More sharing options...
Synook Posted December 17, 2007 Share Posted December 17, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.