0
<?php
....
$sql = "SELECT * FROM items ORDER BY item_id DESC";
$query = mysqli_query($con, $sql);
while ($row_item=mysqli_fetch_array($query)){
    $id = $row_item['item_id'];
    $title = $row_item['item_title'];
    $image = $row_item['item_image'];
    $trailer = $row_item['item_trailer'];

    echo "
        <div class='col-sm-3'>
           <img src='item-images/$image' />
           <p>$title</p>
            <a href='' class='launch-modal' data-modal-id='modal-video'>Trailer</a>

            <!--Modal-->
            <div class='modal fade' id='modal-video' tabindex='-1' role='dialog'>
                <div class='modal-dialog'>
                    <div class='modal-content'>
                        <div class='modal-header'>
                            <button type='button' class='close' data-dismiss='modal'>Close</button>
                            <h4 class='modal-title'>$title</h4>
                        </div>
                        <div class='modal-body'>
                            <div class='modal-video'>
                                <video id='video-frame' controls src='item-trailer/$trailer'></video>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div> <!--.col-sm-3-->
    ";
    ?>

How can i make this $trailer launch inside modal dialog with it's own id?

i already try this but it's not working: href='index.php?$id'

FYI: This is the old one which targeted to the other page without modal dialog:

echo " href='trailer.php?single_id=$id' ";

<!--The Other Page-->
<?php
if(isset($_GET['single_id'])){
$item_id = $_GET['single_id'];
$get_item = "SELECT * FROM items WHERE item_id='$item_id'";
$run_item = mysqli_query($con, $get_item);
while ($row_item=mysqli_fetch_array($run_item)){

    $theID = $row_item['item_id'];
    $theTitle = $row_item['item_title'];
    $theTrailer = $row_item['item_trailer'];
    echo "
         <video controls src='item-trailer/$theTrailer'></video>
         <p>$theTitle</p>

    ";
}
}
?>

For more review, i give the javasript that execute the page:

$(function(){
// open the modal
$('.launch-modal').on('click', function(e){
e.preventDefault();
$( '#' + $(this).data('modal-id') ).modal();
}); // reload the modal contents when it is closed
$("#modal-video").on("hidden.bs.modal", function () {
var url = $('#video-frame').attr('src');
$('#video-frame').attr('src', '');
$('#video-frame').attr('src', url);
});
});
Fanya
  • 1
  • 1
  • 6
  • Isn't your code doing exactly what you want? It outputs the video into the modal. You can set the ID with ` – Obsidian Age May 25 '17 at 00:09
  • yes i already try this but it's not what i expected. its execute all the id on the page: This is not working: 'index.php?$id – Fanya May 25 '17 at 00:14
  • I just told you how to call it. `index.php?item_id=1` is not the same as `index.php?$id`. You need `index.php?item_id=$id`. – Obsidian Age May 25 '17 at 00:16
  • ok thanks. let me try this first. – Fanya May 25 '17 at 00:19
  • Are you trying to open the model when its respective link clicked? – manian May 25 '17 at 00:20
  • @manian yes. i need only the one id that i clicked. – Fanya May 25 '17 at 01:35
  • @ObsidianAge Still not working. FYI: There is 8 items with different id showing up on the page. And when i click 1 of them, it's taken only this one id where the id is sit on the top of ORDER (BY DESC) – Fanya May 25 '17 at 01:49
  • @Fanya maybe my answer can help you, https://stackoverflow.com/questions/44146701/sending-user-a-mesage-by-passing-their-id-to-a-modal-box/44146997#44146997 – KaoriYui May 25 '17 at 05:19
  • Can you please try this, data-modal-id='modal-video{$id}' in your link & id='modal-video{$id}' in your model – manian May 25 '17 at 06:24
  • @manian not working – Fanya Jun 11 '17 at 09:08
  • I think there are couple of items to fix. One, you need to fix the issue to open the correct popup on clicking on the respective buttons. You need not worry about the videos. You can even remove the video related jquery code. Once popup fixed, then you can fix the video part. – manian Jun 12 '17 at 05:39

0 Answers0