drz73366 2012-06-15 15:28
浏览 96
已采纳

清除div并重新加载新的音频内容

I have a database which contains the link to audio files. I am trying to play them one after the other using the HTML audio tag. Presently I am using PHP. My code -

    $sql = "SELECT * FROM table";
    $r = mysql_query($sql);

       while($row = mysql_fetch_array($r)) {
            $id = $row["audID"];                                                
            $audsq = "SELECT * FROM table2 WHERE id ='$id'";            
            $resultaud = mysql_query($audsq);

            //Here I want to write a code to clear div="test"

            PlayAud(resultaud);
            sleep(2);   ///Not Sure             
        }

I am passing the link to aud file for the html to load and in

 <?php
      PlayAud($res) {
          $raud = mysql_fetch_array($res); ?>
      <div id="test">
      <audio> ...  </audio>
      </div>
 <?php }?>

Can some one tell me if I am doing it right ? also each clip is of 2 seconds hence I need to wait in the while loop for 2 seconds. If there is any other way can you suggest me?

Thank You

  • 写回答

3条回答 默认 最新

  • doutidi5037 2012-06-15 15:37
    关注

    You cannot clear a div from php. The reason is that php is running on the server, and the div is echoed out to the client, where it is unreachable by php.

    A solution here could be to use Client side scripting (with JavaScript). You'd program a function, which replaces the audio tag or its contents, and it would probably be a good idea to implement some preloading-mechanism as well.

    Greetings, Jost

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里