lavashark.com
10-03-2005, 10:01 PM
Visitors can rate authors on my site.
I display the average rating via:
<?php echo $admin_authoravgrating.':'.$authoravgrating ?>
How can I limit the return
from:
Average Rating::4.258095391
to:
Average Rating::4.25
This might help:
function getauthorbyid2($authorid)
{
$sql = "SELECT a.*,count(*) AS cnt,avg(n.rating) AS avgrating FROM authors a join news n on a.authorid=n.authorid WHERE a.authorid='$authorid' GROUP BY authorid";
$result = $this->select($sql);
return $result;
}
I display the average rating via:
<?php echo $admin_authoravgrating.':'.$authoravgrating ?>
How can I limit the return
from:
Average Rating::4.258095391
to:
Average Rating::4.25
This might help:
function getauthorbyid2($authorid)
{
$sql = "SELECT a.*,count(*) AS cnt,avg(n.rating) AS avgrating FROM authors a join news n on a.authorid=n.authorid WHERE a.authorid='$authorid' GROUP BY authorid";
$result = $this->select($sql);
return $result;
}