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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement