-1

我正在开发其中 XML 是我的播放列表的视频播放器。这是代码:

$crxml=file_get_contents('http://spoti.com/latest.xml/?lang=en');    
$rss=new SimpleXMLElement($crxml);
$playlistitem=1;
   foreach($rss->channel->item as $post)
    {   
    if($playlistitem<=8)
    {    
    echo '<ul>';
    echo '<li class="xtitle">'.$post->title.'</li>';
    echo '<li class="xdesc">'.$post->description.'</li>';    
    $dc=$post->children('http://search.yahoo.com/mrss/');
    echo '<li class="xthumb">'.$dc->thumbnail->attributes()->url.'</li>';
    echo '<li class="xpreview">'.$dc->thumbnail->attributes()->url.'</li>'; 
    echo '<li class="xsources_mp4">'.$dc->content->attributes()->url.'</li>';
    $dc->content->attributes()->url=preg_replace('/.mp4/','.webm',$dc->content-attributes()->url);
     echo '<li class="xsources_webm">'.$dc->content->attributes()->url.'</li>';
     echo '</ul>';
    $playlistitem++;
     }

当用户单击语言时,我想用新内容替换旧内容所有条目都替换为新条目

4

2 回答 2

1

如果我没记错的话,一旦页面加载,PHP 就完成了它的工作,不能再做更多了。
如果您想在页面加载后更改某些内容,您应该尝试类似 jquery:

<script>
  $("Class_or_ID_of_button").click(function () {
  $('div_or_span_to_change').html('this will appear once you click the button');
});
</script>

不过我不是专家,所以我需要更多信息才能给你一个准确的代码来帮助你......希望这会有所帮助!


http://api.jquery.com/click/
http://api.jquery.com/html/

于 2012-04-07T04:08:17.837 回答
0
$('#lang').change(function() {
$.post('player_xml.php', {lang: $(this).val()}, function(data) {
    $('#xplaylist').html(data);

        $lang =strtolower( issset($_GET['lang'] ) ? $_GET['lang']:'en');
     $crxml=file_get_contents('http://spoti.com/latest.xml/?lang='. $lang); 
    $rss=new SimpleXMLElement($crxml);
      $playlistitem=1;
      foreach($rss->channel->item as $post)       
     if($playlistitem<=8)        
echo '<ul>';
echo '<li class="xtitle">'.$post->title.'</li>';
echo '<li class="xdesc">'.$post->description.'</li>';    
$dc=$post->children('http://search.yahoo.com/mrss/');
echo '<li class="xthumb">'.$dc->thumbnail->attributes()->url.'</li>';
echo '<li class="xpreview">'.$dc->thumbnail->attributes()->url.'</li>'; 
echo '<li class="xsources_mp4">'.$dc->content->attributes()->url.'</li>';
$dc->content->attributes()->url=preg_replace('/.mp4/','.webm',$dc->content-attributes()->url);
 echo '<li class="xsources_webm">'.$dc->content->attributes()->url.'</li>';
 echo '</ul>';
$playlistitem++;
于 2012-04-12T17:04:06.017 回答