PHP Classes

File: WIAdmin/WIModule/modules/avg_temp.php

Recommend this page to a friend!
  Classes of Jules Warner   WICMS   WIAdmin/WIModule/modules/avg_temp.php   Download  
File: WIAdmin/WIModule/modules/avg_temp.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: WICMS
Database driven content management system with PDO
Author: By
Last change:
Date: 6 years ago
Size: 788 bytes
 

Contents

Class file image Download
<?php

include_once 'core/init.php';
if (isset(
$_GET['id'])) {
   
// Connect to the MySQL database

   
$id = preg_replace('#[^0-9]#i', '', $_GET['id']);
}
   
$sql = mysql_query("SELECT ratings FROM books WHERE id='$id'");
while(
$row = mysql_fetch_array($sql))
{
   
$mybooknum = $row["ratings"];
   
$bookrating = explode(",", $mybooknum);
   
$count = count($bookrating);
   
$sum = array_sum($bookrating);
   
$avg = $sum / $count;
   
$roundup = floor($avg);
   
    if(
$roundup == 0)
    {
       
$rating = "This book has not been rated. You can be the first to rate this book.";
    }else if (
$count == 1)
    {
       
$rating = "Average rating for the book is currently $roundup<b />This book has been rated by $count person.";
    }else
    {
       
$rating = "Sorry, there is an error in the system... Please try refreshing.";
    }
}

?>