1

I'm using JWPlayer6 (non-commercial version) and I'm facing a serious problem, using a while loop to loop over all videos from a MySQL database using PHP. Unfortunately, the web page just shows one video from MySQL. When I checked the code in Chrome, I saw that inside the <div id='my-video'></div>, there's nothing to show. How should I fix the problem?

<?php
$result = mysql_query("SELECT * FROM schoolvideo GROUP BY folderName ORDER BY id desc");
while($data = mysql_fetch_array($result)) {
  $id = $data['id'];
  $video = $data['video'];
  $folderName = $data['folderName'];
?>
<div class="square">
  <div id='my-video'></div>
  <script type="text/javascript">
  jwplayer('my-video').setup({
    file: 'http://abc.com/video/<?php echo $folderName; ?>/<?php echo $video; ?>',
    width: '370',
    height: '270',
    primary: 'flash',
    image: 'http://abc.com/img/poster.png',
    autostart: false
  });
  </script>
</div>
<?php
}
?>
1
  • One video is loaded fine and it's working with jwplayer?? To debug the code try echo $id, $video, $folderName in while loop.
    – sven
    Commented May 8, 2013 at 5:22

1 Answer 1

1

Your loop will generate multiple divs with the same id "my-video". You should make them unique.

<div id='my-video-<?php echo $id ?>'></div>
...
jwplayer('my-video-<?php echo $id ?>').setup({...
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.