Hello,
I am trying to make a survey in PHP, using MySQL and I am having a problem with the mathematic problems. I want to work out the percentage by dividing two outcomes and then multiplying them by 100. Here's the code:
$query = "SELECT count(final.answer_id) as answertotal, count(final.question_id) as questiontotal, answers.answer FROM final, answers WHERE final.answer_id=answers.answer_id AND final.question_id=7 GROUP BY answers.answer";
$result = mysqli_query ($dbc, $query);
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
// Display each record.
echo " <tr>
<td width=\"75%\">
<img src=\"line.JPG\"width=\"({$row['answertotal']}/{$row['questiontotal']})*100\" height=\"10\">
</td>
<td width=\"*%\">
{$row['answer']} {$row['answertotal']}
</td>
</tr>
";
It prints out 2/2*100 instead of working out the answer. Can anyone help me? Thank you!