Jump to content

Warning: Division by zero in ....


Digiboy

Recommended Posts

Hi guys, 

 

I have been scratching my head all day long to resolve error division by zero in code below:

 

any thoughts? Thank you

 

<ul>

<?php 

echo "<script type='text/javascript' src='lib/js/jquery.min.js'></script>
	<script type='text/javascript' src='lib/jquery.raty.min.js'></script>";
$rating_cnt = 0;

		while($row = mysql_fetch_array($result))
		{

       $bus_name=$row['name'];
       $bus_address_1=$row['address_1'];
       $bus_address_2=$row['address_2'];
       $bus_address_3=$row['address_3'];
       $bus_town=$row['town'];
       $bus_country=$row['country'];
       $bus_postcode=$row['potscode'];
       $bus_tel=$row['tel'];
	   $bus_website=$row['website'];
       $bus_video=$row['video_link'];
       $bus_about=$row['about'];


       $select=mysql_query("SELECT * FROM towns WHERE id='$bus_town'"); while($myrow=mysql_fetch_array($select)) {$new_town=$myrow['town'];}
        
        
        ///////
		echo "
<div class='business_list'>
<div class='business-bars light-blue'><div class='business-bar-txt'>$bus_name, $new_town</div></div>

<div class='business-row'>
<div class='business-vimeo'><iframe src='http://player.vimeo.com/video/$bus_video' width='150' height='150' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></span></div>
<div class='business-about'>$bus_about</div>
</div>
<div class='row2'>
<div class='bus_vote'>";


$rating_cnt++;
if(isset($_SESSION['account_no']) && $_SESSION['account_no']!='')
{
echo "<input type='hidden' id='prd_id_".$rating_cnt."' name='prd_id_".$rating_cnt."' value='".$myrow['prd_id']."' />
	<div id='business_rate_".$rating_cnt."'></div>
	<script type='text/javascript'>
		$(function() {
		  $.fn.raty.defaults.path = 'lib/img';
	
		  $('#business_rate_".$rating_cnt."').raty({
			path     : 'lib/img',
			cancel   : false,
			cancelOff: 'cancel-off-big.png',
			cancelOn : 'cancel-on-big.png',
			half     : false,
			size     : 24,
			starHalf : 'star-half-big.png',
			starOff  : 'star-off-big.png',
			starOn   : 'star-on-big.png',
			click: function(score, evt) {
				var prd_id = $('#prd_id').val();
				$.ajax({
					type: 'POST',
					url: 'add_rate.php',
					data: { bid: prd_id, rating:score }
					}).done(function( msg ) {
						alert('You add rating on this business successfully.');
				});
			}
		  });
		});
	</script>";
}
else
{
	$total_rate = 0;
	$rating_qry = "SELECT * FROM business_rating WHERE bid='".$myrow['prd_id']."'";
	$rating_res = mysql_query($rating_qry) or die(mysql_error());
	$count_rating = mysql_num_rows($rating_res);
	while($rating_row = mysql_fetch_array($rating_res))
	{
		$total_rate += $rating_row['rate'];
	}
	
	$rating_score =round($total_rate/$count_rating);
	
	echo "<div id='business_rate_".$rating_cnt."'></div>
	<script type='text/javascript'>
		$(function() {
		  $.fn.raty.defaults.path = 'lib/img';
	
		  $('#business_rate_".$rating_cnt."').raty({
			path     : 'lib/img',
			cancel   : false,
			cancelOff: 'cancel-off-big.png',
			cancelOn : 'cancel-on-big.png',
			half     : false,
			size     : 24,
			readonly : true,
			score 	 : ".$rating_score.",
			starHalf : 'star-half-big.png',
			starOff  : 'star-off-big.png',
			starOn   : 'star-on-big.png'
		  });
		});
	</script>";
}
//////////////////

echo"
</div>
<div class='bus_address'><div class='business-bar-txt'>$bus_address_1,$bus_address_2, $bus_address_1</div></div></div>
</div>
<div class='row3'>
<div class='bus_reviews'></div><div class='bus_phone'></div><div class='bus_website'></div>
</div>
<!--    end of row       -->
";
}
	 echo "<div class='results'>$total_pages Results</div>";
 // pagination
 echo $paginate;
	?>
</ul>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.