<?php 
session_start();
  error_reporting(E_ALL);
  ini_set('display_errors', 'On');
try {
    $con = new PDO('mysql:host=localhost;dbname=interactivos', 'aofreew', 'conexioneS.118e', array( PDO::ATTR_PERSISTENT => true));
    $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $res=$con->query('SELECT nombre,slug,jj,jg,jp,je,gf,gc,dg,pts FROM  equipos order by pts desc,dg desc',PDO::FETCH_ASSOC);
    $row=$res->fetchAll();
    // var_dump($row[0]['idequipos']);
    // echo "<br>";
  } catch (PDOException $e) {
    print "¡Error!: " . $e->getMessage() . "<br/>";
    die();
}

$con2 = mysqli_connect("localhost","aofreew","conexioneS.118e","interactivos") or die("Ocurrio algun error durante la conexion! " . mysqli_error($con2));
$json = array();
$dias = array( 1=>'Lunes',2=>'Martes',3=>'Miercoles',4=>'Jueves',5=>'Viernes',6=>'Sabado',7=>'Domingo' );
$meses = array(1=>'Enero',2=>'Febrero',3=>'Marzo',4=>'Abril',5=>'Mayo',6=>'Junio',7=>'Julio',8=>'Agosto',9=>'Septiembre',10=>'Octubre',11=>'Noviembre',12=>'Diciembre');
for ($i=1; $i <=17 ; $i++) { 
    $query = "select j.idjuego,equipo_a as slug_a,equipo_b as slug_b,(select jn.texto from jornada jn where jn.idjornada=j.jornada) texto, (select e.nombre from equipos e where e.slug=j.equipo_a) equipo_a, (select ee.nombre from equipos ee where ee.slug=j.equipo_b) equipo_b, j.goles_a, j.goles_b, j.fecha, j.estadio, j.display from juegos j where j.jornada={$i}";
    $res2 = mysqli_query($con2, $query);
    while($row2 = mysqli_fetch_array($res2)) {
      $fecha = $row2['fecha'];
      $dia = date('d', $fecha);
      $diaStr = $dias[date('N', $fecha)];
      $mesStr = $meses[date('n',$fecha)];
      $year = date('Y',$fecha);
      $hora = date('H:i',$fecha);
      $fechaStr = $dia.' '.$mesStr.', '.$year;
      $items[] = array(
        'texto' =>utf8_encode($row2['texto']),
        'idjuego'=>utf8_encode($row2['idjuego']),
        'equipo_a'=>utf8_encode($row2['equipo_a']),
        'equipo_b'=>utf8_encode($row2['equipo_b']),
        'slug_a'=>utf8_encode($row2['slug_a']),
        'slug_b'=>utf8_encode($row2['slug_b']),
        'diaStr'=>utf8_encode($diaStr),
        'fechaStr'=>utf8_encode($fechaStr),
        'timestamp'=>utf8_encode($fecha),
        'hora'=>utf8_encode($hora),
        'goles_a'=>$row2['goles_a'],
        'goles_b'=>$row2['goles_b'],
        'estadio'=>(empty($row2['estadio']) ? ' ' : $row2['estadio']),
        'display'=>$row2['display']
       );
    }
    $json[$i] = $items;
    unset($items);
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>El Universal | Calendario Liga MX</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width">
  <meta name="robot" content="index,follow" />
  <meta name="mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="keywords" content="Liguilla Apertura 2017, Fútbol Mexicano, Estadisticas, Encuentros, Futbol, Partidos, Noticias, Minuto a minuto." />
  <meta name="author" content="El Universal, Compañia Periodística Nacional. México">
  <meta name="description" content="EL UNIVERSAL, periódico líder en noticias de México y el mundo minuto por minuto; información que te interesa sobre mundo, ciudad">
  <meta name="description" content="Sitio líder de noticias minuto x minuto de México y el mundo, con información sobre política, ciudad, videos, interactividad, opinión, blogs" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

  <!--Open Graph data-->
  <meta property="og:title" content="Calendario Liga MX"/>
  <meta property="og:url" content="http://interactivo.eluniversal.com.mx/2017/liga-mx-calendario/" />
  <meta property="og:type" content="website"/>
  <meta property="og:description" content="Master-Templete" />
  <meta property="og:image" content="http://interactivo.eluniversal.com.mx/2017/liga-mx-calendario/img/face.jpg" />
  <meta property="og:image" content="http://interactivo.eluniversal.com.mx/2017/liga-mx-calendario/img/face.jpg" />
  <meta property="og:description" content="http://interactivo.eluniversal.com.mx/2017/liga-mx-calendario/img/facebook-liga-mx.jpg" />

  <!--Twitter Card-->
  <meta name="twitter:card" content="summary" />
  <meta name="twitter:title" content="Calendario Liga MX" />
  <meta name="twitter:description" content="Master-Templete" />
  <meta name="twitter:url" content="http://interactivo.eluniversal.com.mx/2017/liga-mx-calendario/" />
  <meta name="twitter:image" content="http://interactivo.eluniversal.com.mx/graficos/2017/liga-mx-calendario/img/twitter-liga-mx.jpg" />

  <!-- Favicon -->
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
  <link rel="manifest" href="/manifest.json">
  <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#005383">
  <meta name="theme-color" content="#005383">
  <!-- Termina Favicon)-->

  <!-- Bootstrap Core CSS -->
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <!-- Custom Fonts -->
  <link href="css/font-awesome.min.css" rel="stylesheet">
  <!-- Theme CSS -->
  <link href="css/grayscale.min.css" rel="stylesheet">
  <!-- Sport Css-->
  <link rel="stylesheet" id="sportspress-general-css" href="css/sportspress.css" type="text/css" media="all">
  <link rel="stylesheet" id="rookie-framework-style-css" href="css/framework.css" type="text/css" media="all">
  <link rel="stylesheet" id="rookie-style-css" href="css/style.css" type="text/css" media="all">
  <link rel="stylesheet" id="rookie-style-css" href="css/style2.css" type="text/css" media="all">
  <link rel="stylesheet" id="icons-css" href="css/dashicons.min.css" type="text/css" media="all">
  <!-- Sport Script -->
  <script type="text/javascript" src="js/jquery.js"></script>
  <!-- Js de contador -->
  <script type="text/javascript" src="js/jquery-migrate.min.js"></script>
  <!-- Mantiene en su sitio al logo en responsive -->

  <!-- Owl -->
  <link rel="stylesheet" type="text/css" href="css/owl.css">
  <style>
.navbar-toggler {
  z-index: 1;
}

@media (max-width: 576px) {
nav > .container {
  width: 100%;
}
}

.sp-event-results-alter{ min-height: 7px; }
</style>
  <!-- FInal de Mantiene en su sitio al logo en responsive -->
  <!-- Accordion -->
  <link rel="stylesheet" href="css/jquery-ui.css">
  <script src="js/jquery-1.12.4.js.js"></script>
  <script src="js/jquery-ui.js"></script>
  <script>
  $(document).ready(function(){

      $( ".accordion" ).accordion({
        heightStyle: "content"
      });

  });
  </script>
  </head>

  <body id="page-top" class="contenedor"  style="background-color:#000000; width: 100%; height: 880px; overflow: hidden;">

<!--Inicia segundo section--> <!-- La caja de modales en la linea 253-->
<section id="team" class="gray-bg" style="width: 100%">
    <div class="container-fluid" >
     <!--<div class="title text-center">
        <h2 style="text-align: center;">Estadísticas</h2>
     <h4 class="light muted">Los mejores del juego</h4>
        <hr class="one">
      </div>-->
      <a href="http://interactivo.eluniversal.com.mx/ligamx/index.php" target="new" style="color:#FFFFFF;">
    <div class="row" > 
        
        <!-- Comienza el ranking de juego -->
        <div class="sp-widget-align-none" style="width: 100%">
        <aside id="sportspress-player-list-3" class="widget widget_sportspress widget_player_list widget_sp_player_list">
            <h4 class="sp-table-caption frag"><span class="jornada-lat">Tabla gral.</span> <span class="margenes">Apertura <?php echo date('Y'); ?></span></h4>
            <div class="sp-template sp-template-player-list">
            <div class="sp-table-wrapper">
                <div class="sp-scrollable-table-wrapper">
                <div id="DataTables_Table_2_wrapper" class="dataTables_wrapper no-footer">
                    <div class="sp-scrollable-table-wrapper">
                    <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
                        <table class="sp-league-table sp-data-table sp-sortable-table sp-scrollable-table sp-paginated-table dataTable no-footer" data-sp-rows="18" id="DataTables_Table_0" role="grid">
                        <thead>
                            <tr role="row">
                            <th class="data-rank sorting tam" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Pos">Pos</th>
                            <th class="data-name sorting tam" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Team">Equipo</th>
                            <th class="data-pts sorting tam" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Pts">Pts</th>
                          </tr>
                          </thead>
                        <tbody>
                            <?php foreach ($row as $iterador => $value){?>
                            <tr class="sp-row-no-0 odd" role="row">
                              <td class="data-rank text-right " ><?php echo $iterador+1 ?></td>
                              <td class="data-name has-logo "><span class="team-logo"><img width="80" height="110" src="img/teams/<?php echo $value['slug'] ?>.png" class="attachment-sportspress-fit-icon size-sportspress-fit-icon wp-post-image" alt="" sizes="(max-width: 100px) 100vw, 100px"></span></td>
                              
                              <td class="data-pts color"><?php echo $value['pts'] ?></td>
                            </tr>
                            <?php } ?>
                          </tbody>
                      </table>
                      </div>
                  </div>
                  </div>
              </div>
              </div>
          </div>
          </aside>
      </div>
        <!-- Termina el ranking de juego --> 
      </div>
		</a>
  </div>
  </section>
<!--Termina segundo section--> 

<!-- Comienzan Scripts --> 
<!-- jQuery Version 3.1.1 --> 
<script src="js/jquery.js"></script> 
<!-- Bootstrap Core JavaScript --> 
<script src="js/bootstrap.min.js"></script> 
<!-- Plugin JavaScript & Scrolling --> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script> 
<!-- Theme JavaScript --> 
<script src="js/grayscale.min.js"></script> 
<!-- Organización de tablas --> 
<script type="text/javascript" src="js/jquery.dataTables.min.js"></script> 
<!-- Comienza Cuenta Regresiva --> 
<script type="text/javascript" src="js/jquery.countdown.min.js"></script> 
<script type="text/javascript">
/* <![CDATA[ */
var localized_strings = {"days":"Días","hrs":"hrs","mins":"mins","secs":"segs","previous":"Prev","next":"Sig"};
/* ]]> */</script> <!-- Termina Cuenta Regresiva --> 
<!-- Complemento de tablas --> 
<script type="text/javascript" src="js/sportspress.js"></script> 
<!-- Codigo JS para animaciones y comportamientos --> 
<script src="js/main.js"></script>

<!-- Terminan Scripts -->
</body>
  <!-- Inicia comScore Certifica code 1.1104.26-->
  <script type="text/javascript">
// <![CDATA[
function comScore(t){var b="comScore",o=document,f=o.location,a="",e="undefined",g=2048,s,k,p,h,r="characterSet",n="defaultCharset",m=(typeof encodeURIComponent!=e?encodeURIComponent:escape);if(o.cookie.indexOf(b+"=")!=-1){p=o.cookie.split(";");for(h=0,f=p.length;h<f;h++){var q=p[h].indexOf(b+"=");if(q!=-1){a="&"+unescape(p[h].substring(q+b.length+1))}}}t=t+"&ns__t="+(new Date().getTime());t=t+"&ns_c="+(o[r]?o[r]:(o[n]?o[n]:""))+"&c8="+m(o.title)+a+"&c7="+m(f&&f.href?f.href:o.URL)+"&c9="+m(o.referrer);if(t.length>g&&t.indexOf("&")>0){s=t.substr(0,g-8).lastIndexOf("&");t=(t.substring(0,s)+"&ns_cut="+m(t.substring(s+1))).substr(0,g)}if(o.images){k=new Image();if(typeof ns_p==e){ns_p=k}k.src=t}else{o.write('<p><'+'img src="'+t+'" height="1" width="1" alt="*"></p>')}};
comScore('http'+(document.location.href.charAt(4)=='s'?'s://sb':'://b')+'.scorecardresearch.com/p?c1=2&c2=6906641&ns_site=el-universal&name=eluniversal.Graficos.liga-mx-calendario');
// ]]>
</script>
  <noscript>
  <p><img src="http://b.scorecardresearch.com/p?c1=2&amp;c2=6906641&amp;ns_site=el-universal&amp;name=el-universal.Graficos.liga-mx-calendario" height="1" width="1" alt="*"></p>
  </noscript>
  <!-- Fin comScore Certifica-->
  <!--Código de Google Analytics-->
  <script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
  <script type="text/javascript">
var pageTracker = _gat._getTracker("UA-5566785-1");
pageTracker._trackPageview();
</script>
  <!--Fin de Google Analytics-->
  <!-- Contador interno// -->
  <script language="JavaScript" src="http://hits.eluniversal.com.mx/accesos/accesos_detalle.php?p_id_nota=1890&var_secc=500&var_cabeza=liga-mx-calendario"></script>
</html>