<style> body{ background-size: cover; background-position: center; background-attachment: fixed; background-image: url(<?php echo $url; ?>/img/bg_juegos.jpg); } </style> <div class="col-md-12"> <div class="container" > <?php echo $rersp; ?> <div class="row"> <div class="col-md-12" align="center"> <h1 style="color: #ffffff;">RANKING</h1> </div> <div class="col-md-6" align="center" style="color: #ffffff;"> <h3>Crucigrama</h3> <hr> <table class="table table-bordered" style="color: #ffffff"> <tr> <th scope="col">PosiciĆ³n</th> <th scope="col">Participante</th> <th scope="col">Puntaje</th> </tr> <?php $arrayRanking = array(); $count = 1; $queryR1 = mysqli_query($connect,"SELECT SUM(porcentaje), SUM(tiempo), id_asistente FROM Retos WHERE tipo_juego = 1 GROUP BY id_asistente "); while($dataR1 = mysqli_fetch_array($queryR1)){ $queryAsi = mysqli_query($connect,"SELECT * FROM Asistentes WHERE id = '".$dataR1['id_asistente']."' "); $dataAsi = mysqli_fetch_array($queryAsi); $puntaje = ( $dataR1["SUM(porcentaje)"]*20 / ( $dataR1["SUM(tiempo)"] / 3 ) ); array_push($arrayRanking, array( "id_asistente" => $dataR1['id_asistente'], "asistente" => ($dataAsi["nombre"].' '.$dataAsi["apellidos"]), "puntaje"=>$puntaje ) ); $count++; } usort($arrayRanking, 'sort_by_orden'); function sort_by_orden ($a, $b) { return $b['puntaje'] - $a['puntaje']; } $count = 1; foreach($arrayRanking as $ranking){ echo ' <tr> <td>'.$count.'</td> <td>'.$ranking["asistente"].'</td> <td>'.round($ranking["puntaje"]).' pts.</td> <tr> '; $count++; } ?> </table> </div> <div class="col-md-6" align="center" style="color: #ffffff;"> <h3>Encuentre la frase</h3> <hr> <table class="table table-bordered" style="color: #ffffff"> <tr> <th scope="col">PosiciĆ³n</th> <th scope="col">Participante</th> <th scope="col">Puntaje</th> </tr> <?php $arrayRanking = array(); $count = 1; $queryR1 = mysqli_query($connect,"SELECT SUM(porcentaje), SUM(tiempo), id_asistente FROM Retos WHERE tipo_juego = 2 GROUP BY id_asistente "); while($dataR1 = mysqli_fetch_array($queryR1)){ $queryAsi = mysqli_query($connect,"SELECT * FROM Asistentes WHERE id = '".$dataR1['id_asistente']."' "); $dataAsi = mysqli_fetch_array($queryAsi); $puntaje = ( $dataR1["SUM(porcentaje)"]*10 / ( $dataR1["SUM(tiempo)"] / 3 ) ); array_push($arrayRanking, array( "id_asistente" => $dataR1['id_asistente'], "asistente" => ($dataAsi["nombre"].' '.$dataAsi["apellidos"]), "puntaje"=>$puntaje ) ); $count++; } usort($arrayRanking, 'sort_by_orden'); $count = 1; foreach($arrayRanking as $ranking){ echo ' <tr> <td>'.$count.'</td> <td>'.$ranking["asistente"].'</td> <td>'.round($ranking["puntaje"]).' pts.</td> <tr> '; $count++; } ?> </table> </div> </div> </div> </div>