Ver Mensaje Individual
  #7 (permalink)  
Antiguo 07/11/2014, 15:45
miriamgomez
 
Fecha de Ingreso: abril-2008
Mensajes: 348
Antigüedad: 16 años
Puntos: 1
Respuesta: Reproducir un audio con una imagen

Código PHP:
Ver original
  1. <?php
  2.  
  3. $registros = 15;
  4. $SrcImg = ''; //agregue esta variable que es donde asignaremos la ruta de la imagen =D
  5. $ScaleImg = ''; //esta variable obtendra el nuevo ancho y alto de tu imagen...
  6. if(!$_GET['pagina']){
  7.     $inicio = 0;
  8.     $_GET['pagina'] = 1;
  9. }else{
  10.     $inicio = ($_GET['pagina'] - 1) * $registros;
  11. }
  12.  
  13. function imageResize($width, $height, $_MaxWidth, $_MaxHeight, $OtherPass) {
  14.     if ($width > $height) {
  15.       $percentage = ($_MaxWidth / $width);
  16.     } else {
  17.       $percentage = ($_MaxHeight / $height);
  18.     }
  19.       $width = round($width * $percentage);
  20.       $height = round(($height * $percentage));
  21.       if($width > $_MaxWidth){
  22.         $TempWidth = ($width - $_MaxWidth);
  23.         $width = ($width - $TempWidth);
  24.         $height = ($height - $TempWidth);
  25.       }
  26.       if($height > $_MaxHeight){
  27.         $TempHeight = ($height - $_MaxHeight);
  28.         $height = ($height - $TempHeight);
  29.         $width = ($width - $TempHeight);
  30.       }
  31.       if($OtherPass){
  32.         imageResize($width, $height, $_MaxWidth, $_MaxHeight, false);
  33.       }
  34.       return "width=\"$width\" height=\"$height\"";
  35. }
  36.  
  37.  
  38. $resultados = mysql_query("SELECT * FROM animales order by id asc") or die(mysql_error());
  39. $total_registros = mysql_num_rows($resultados);
  40. $resultados = mysql_query("SELECT * FROM animales order by id asc LIMIT $inicio, $registros") or die(mysql_error());
  41. $total_paginas = ceil($total_registros / $registros);
  42.  
  43. $qry=$resultados;
  44.  
  45.  
  46. //aqui leer resultados y guardarlos en $resultados
  47. $qry=$resultados;
  48. echo "
  49.  
  50. <table width='500' border='1' align='center' bordercolor='#000066'>
  51. ";
  52. $columnas = 3;
  53. while ( $row=mysql_fetch_assoc($qry) ) {
  54.     if ( $columnas == 3 ) {
  55.         echo "<tr>";
  56.     }
  57.    
  58.     echo "<td >";
  59.  
  60.     $SrcImg = '../../objetos/animales/'.$row['id'].'.jpg';
  61.     $ImgSize = getimagesize($SrcImg);
  62.     $ScaleImg = imageResize($ImgSize[0], $ImgSize[1], 76, 100, true);
  63.     echo "
  64.     <table  align='center'>
  65.  <tr>
  66.      <td rowspan='2'><audio id='audioTestElem' src='../../audio/animales/$row[solucion].mp3' autobuffer >
  67. </audio>
  68. <div onclick='audioTestElem.play()'><img src='$SrcImg' $ScaleImg</div> </td>
  69.    <td rowspan='2'><img src='$SrcImg' $ScaleImg></td>
  70.    <td style='color:#CC3300' >$row[solucion]</td>
  71.  </tr>
  72.  <tr>
  73.    <td >$row[espanol]</td>
  74.  </tr>
  75. </table>
  76. ";
  77.  
  78.     echo "</div>
  79. <div id='3inf'>
  80. </div><br></td>";
  81.    
  82.    
  83.     $columnas--;
  84.     if ( $columnas == 0 ) {
  85.         echo "</tr>";
  86.         $columnas = 3;
  87.     }
  88. }
  89. echo "</table>";
  90.  
  91.  
  92. if($_GET['pagina'] > 1) {
  93. echo "<a href='http://aprendiendoinglesejercicios.com/ingles/vocabulario/".$pagina.".php?pagina=1'><< Primera</a> ";
  94. }
  95. if($_GET['pagina'] > 2) {
  96. echo "<a href='http://aprendiendoinglesejercicios.com/ingles/vocabulario/".$pagina.".php?pagina=".($_GET['pagina']-1)."'>< Anterior</a> ";
  97. }
  98.  
  99. for($i=($_GET['pagina']-2); $i <= ($_GET['pagina']+2); $i++){
  100.     if(($i > 0) && ($i <= $total_paginas)){
  101.         if($_GET['pagina'] == $i){
  102.             echo "<b>".$i."</b> ";
  103.         }else{
  104.             echo "<a href='http://aprendiendoinglesejercicios.com/ingles/vocabulario/". $pagina.".php?pagina=$i'>$i</a> ";
  105.         }
  106.     }
  107. }
  108.  
  109. if($_GET['pagina'] < ($total_paginas-1)){
  110. echo " <a href='http://aprendiendoinglesejercicios.com/ingles/vocabulario/".$pagina.".php?pagina=".($_GET['pagina']+1)."'>Siguiente ></a>";
  111. }
  112. if($_GET['pagina'] < $total_paginas){
  113. echo " <a href='http://aprendiendoinglesejercicios.com/ingles/vocabulario/".$pagina.".php?pagina=".$total_paginas."'>Última >></a>";
  114. }
  115. ?>