Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'config.php';
- function total_responses(){
- $stmt = $mysqli->prepare("select COUNT(*) from responces");
- $stmt->execute();
- $stmt->bint_result($num_rows);
- $stmt->fetch();
- return $num_rows;
- }
- function responces_for_age($age){
- $stmt = $mysqli->prepare("select COUNT(responces.id) from responces join images on images.id=responces.image_id where age=?");
- $stmt->bind_param("i", $age);
- $stmt->execute();
- $stmt->bind_result($num_rows);
- $stmt->fetch();
- return $num_rows;
- }
- function average_score(){
- $stmt = $mysqli->prepare("select AVG(score) from responces");
- $stmt->execute();
- $stmt->bind_result($avg_score);
- $stmt->fetch();
- return $avg_score;
- }
- function average_score_for_age($age){
- $stmt = $mysqli->prepare("select AVG(score) from responces join images on images.id=responces.image_id where age=?");
- $stmt->bind_param("i", $age);
- $stmt->execute();
- $stmt->bind_result($avg_score);
- $stmt->fetch();
- return $avg_score;
- }
- function average_score_in_time_period($time_start, $time_end){
- $stmt = $mysqli-prepare("select AVG(score) from responces where datetime >= ? or datetime <= ?");
- $stmt->bind_param("ii", $time_start, $time_end);
- $stmt->execute();
- $stmt->bind_param($avg_score);
- return $avg_score;
- }
- function average_score_for_age_in_time_period($age, $time_start, $time_end){
- $stmt = $mysqli-prepare("select AVG(score) from responces join images on images.id=responces.image_id where age=? and (datetime >= ? or datetime <= ?)");
- $stmt->bind_param("ii", $time_start, $time_end);
- $stmt->execute();
- $stmt->bind_param($avg_score);
- return $avg_score;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement