Search code examples
phpmysqlfor-loopwhile-loopflexslider

Flexslider with php multiple videos


I have a table "videos" with id_video, client, code. And i found this:

http://demo.juanfra.me/multiple-videos-flexslider-v2/

First i tried put the -li- into a while and show all results with mysqli_fetch_array. But i cant show anything. I think the id of each iframe "player_number" must be unique, so do i have to use a for()?

<?php while($rowmulti = mysqli_fetch_array($resultmultimedia)){
echo'
    <li>
        <iframe id="player_1" src="http://player.vimeo.com/video/'.$rowmulti["code"].'?api=1&player_id=player_1"></iframe>
    </li>
';}?>

Maybe the error is in the jquery code but i dont good js programmer. thank you!


Solution

  • You don't necessarily need a for loop. You can just keep track of an $id variable within the loop that increments each iteration.

    Try this:

    <?php
      $id = 1;
      while ($rowmulti = mysqli_fetch_array($resultmultimedia)) {
      echo'
        <li>
          <iframe id="player_' . $id . '" src="http://player.vimeo.com/video/' . $rowmulti["code"] . '?api=1&player_id=player_' . $id . '"></iframe>
        </li>';
        $id++;
      }
    ?>