3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Setup the connection to the database $con=mysqli_connect("mysql11.citynetwork.se","125966-hv96625","SidTheKidCrosby8778","125966-show-ratings"); $showID = get_the_ID(); // Fetch all available columns for the current show with the ID $showID $row = mysqli_fetch_array(mysqli_query($con,"SELECT * FROM `125966-show-ratings`.`ratings_for_shows` WHERE SHOW_ID=$showID")); $show_rating_link = ""; $show_rating_one_count = $row['one_vote']; $show_rating_two_count = $row['two_vote']; $show_rating_three_count = $row['three_vote']; $show_rating_four_count = $row['four_vote']; $show_rating_five_count = $row['five_vote']; $show_rating_six_count = $row['six_vote']; $show_rating_seven_count = $row['seven_vote']; $show_rating_eight_count = $row['eight_vote']; $show_rating_nine_count = $row['nine_vote']; $show_rating_ten_count = $row['ten_vote']; // Count the number of votes available in the database for all the fields $number_of_votes = $show_rating_one_count + $show_rating_two_count + $show_rating_three_count + $show_rating_four_count + $show_rating_five_count + $show_rating_six_count + $show_rating_seven_count + $show_rating_eight_count + $show_rating_nine_count + $show_rating_ten_count; // Count the sum of all the votes $sum_of_votes = 1 * $show_rating_one_count + 2 * $show_rating_two_count + 3 * $show_rating_three_count + 4 * $show_rating_four_count + 5 * $show_rating_five_count + 6 * $show_rating_six_count + 7 * $show_rating_seven_count + 8 * $show_rating_eight_count + 9 * $show_rating_nine_count + 10 * $show_rating_ten_count; // Count the max possible value $max_possible_sum = 10 * $number_of_votes; // Calculate the rating in percent with one decimal maximum $rating = round(($sum_of_votes / ($max_possible_sum) * 100) * 10) / 10;

preferences:
83.39 ms | 402 KiB | 5 Q