Troubleshooting division by zero warning
<p>I want to display like and unlike vote with count. my code is given below but it displays Warning: division by zero in filename.php.</p>

<pre><code>&lt;?php
include("db.php");

if($_POST['id'])
{
$id=mysql_escape_String($_POST['id']);
$name=mysql_escape_String($_POST['name']);

mysql_query("update messages set $name=$name+1 where id='$id'");

$result=mysql_query("select up,down from messages where id='$id'");
$row=mysql_fetch_array($result);

$up_value=$row['up'];
$down_value=$row['down'];
$total=$up_value+$down_value;

$up_per=($up_value*100)/$total;
$down_per=($down_value*100)/$total;
?&gt;
&lt;div style="margin-bottom:10px"&gt;
&lt;b&gt;Ratings for this blog&lt;/b&gt; ( &lt;?php echo $total; ?&gt; total)
&lt;/div&gt;
&lt;table width="700px"&gt;

&lt;tr&gt;
&lt;td width="30px"&gt;&lt;/td&gt;
&lt;td width="60px"&gt;&lt;?php echo $up_value; ?&gt;&lt;/td&gt;
&lt;td width="600px"&gt;&lt;div id="greebar" style="width:&lt;?php echo $up_per; ?&gt;%"&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td width="30px"&gt;&lt;/td&gt;
&lt;td width="60px"&gt;&lt;?php echo $down_value; ?&gt;&lt;/td&gt;
&lt;td width="600px"&gt;&lt;div id="redbar" style="width:&lt;?php echo $down_per; ?&gt;%"&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;/table&gt;

&lt;?php
}
?&gt;
</code></pre>
