treeleaf20 Posted November 16, 2009 Share Posted November 16, 2009 All, I'm trying to add a voting system to my site and when someone submits a form I want a dynamic horizontal bar graph to be displayed. Any ideas on a good script is? I can submit the data, process the data. I just need a script to dsiplay it in a bar graph. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Szandor Posted November 16, 2009 Share Posted November 16, 2009 This would best be done through CSS. Just create an invisible bar through CSS, put another bar inside it and let the PHP write the height of that bar. I'll wing some code by hand, but it's not tested so you might need to tweak it some. PHP: <div class="fullbar"> <div class="percbar" style="height:<? echo $percent; ?>;"> </div> </div> CSS: div.fullbar { width: 1em; height: 20em; } div.fullbar { border: 1px solid #000; background-color: #080; width: 100%; } Just make sure to calculate the height in percentage and save that in the variable "$percent". Quote Link to comment Share on other sites More sharing options...
treeleaf20 Posted November 16, 2009 Author Share Posted November 16, 2009 For some reason this won't work. I put in the CSS and actually change the percbar in the CSS so my CSS looks like this: CSS: div.fullbar { width: 1em; height: 20em; } div.percbar { border: 1px solid #555555; background-color: #fff; width:100%; } And my PHP looks like: <? $percent1 = "90%"; $percent2 = "10%"; ?> </form> <div class="fullbar"> <div class="percbar" style="height:<? echo $percent1; ?>;"> </div> <div class="percbar" style="height:<? echo $percent2; ?>;"> </div> </div> So I just hardcoded the values in for now. They both show up for they are the same size. Any ideas? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.