The below code creates a table that shows a bar graph that with different colors the problem that I’m having is the data that creates each different color bars will not all have the same number of data entires but the sum of the percentages should equal 100% the bars are not keeping to the same length and are spilling over to another row any ideas how to fix this. the total length of all bars need to be the same
[code=php]
<?php
$query_get_survey_questions = “SELECT * FROM `survey`”;
$get_survey_questions = mysql_query($query_get_survey_questions)or die(mysql_error());
while ($survey_question = mysql_fetch_array($get_survey_questions)){ ?>
<?php
if($survey_question[“excellent”] != 0) {
$VoteExcellent = Round(($survey_question[“excellent”] / $survey_question[“total_votes”]) * 100) . “%”;
} else {
$VoteExcellent = 0 .”%”;
}
if($survey_question[“very_good”] != 0) {
$VoteVery_good = Round(($survey_question[“very_good”] / $survey_question[“total_votes”]) * 100) . “%”;
} else {
$VoteVery_good = 0 .”%”;
}
if($survey_question[“good”] != 0) {
$VoteGood = Round(($survey_question[“good”] / $survey_question[“total_votes”]) * 100) . “%”;
} else {
$VoteGood = 0 .”%”;
}
if($survey_question[“fair”] != 0) {
$VoteFair = Round(($survey_question[“fair”] / $survey_question[“total_votes”]) * 100) . “%”;
} else {
$VoteFair = 0 .”%”;
}
if($survey_question[“poor”] != 0) {
$VotePoor = Round(($survey_question[“poor”] / $survey_question[“total_votes”]) * 100) . “%”;
} else {
$VotePoor = 0 .”%”;
}
?>
<tr><td class=”left” style=”width:30%;”><?php echo $survey_question[‘question’] ;?></td>
<td colspan=”2″ class=”rightTwoColumn” style=”width:70%; height:50px;”><img src=”../images/redBar.gif” width=”<?=$VotePoor?>” height=”20″ title=”Poor: <?=$survey_question[“poor”]?> Total:<?=$survey_question[“total_votes”]?> Percent: <?= number_format($survey_question[“poor”] / $survey_question[“total_votes”]*100,2); ?>%” alt=”bar”><img src=”../images/purpleBar.gif” width=”<?=$VoteFair?>” height=”20″ title=”Fair: <?=$survey_question[“fair”]?> Total:<?=$survey_question[“total_votes”]?>Percent: <?= number_format($survey_question[“fair”] / $survey_question[“total_votes”]*100,2); ?>%” alt=”bar”><img src=”../images/yellowBar.gif” width=”<?=$VoteGood?>” height=”20″ title=”Good: <?=$survey_question[“good”]?> Total:<?=$survey_question[“total_votes”]?> Percent: <?= number_format($survey_question[“good”] / $survey_question[“total_votes”]*100,2); ?>%” alt=”bar”><img src=”../images/blueBar.gif” width=”<?=$VoteVery_good?>” height=”20″ title=”Very Good: <?=$survey_question[“very_good”]?> Total:<?=$survey_question[“total_votes”]?> Percent: <?= number_format($survey_question[“very_good”] / $survey_question[“total_votes”]*100,2); ?>% ” alt=”bar”><img src=”../images/greenBar.gif” width=”<?=$VotePoor?>” height=”20″ title=”Excellent: <?=$survey_question[“excellent”]?> Total:<?=$survey_question[“total_votes”]?> Percent: <?= number_format($survey_question[“excellent”] / $survey_question[“total_votes”]*100,2); ?>%” alt=”bar”>
</td>
</tr>