SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Bootstrap modal

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Location
    Bangladesh
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Bootstrap modal

    Hello,

    I need help on bootstrap modal. Suppose, a table contains 5 rows.In above table inside the while loop, first col shows student name and 2nd col shows view profile button.
    when i click view profile button then it calls modal and will show me student details information. In this way when i click view profile button of 2nd student then it call modal and will show me student details of 2nd student. But my problem is i can't do this. I need view profile button will be dynamic. How can i do this ?? Can you please help me??

    //modal function of view student

    PHP Code:
    <?php
    $resultV 
    mysql_query("SELECT * FROM student WHERE id =$ID"); // Here i need dynamic id
    $row mysql_fetch_array($resultV);
    ?>
      <!-- Modal -->
      <div class="modal fade" id="view-student" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
        <div class="modal-dialog"  style=" width:950px;">
          <div class="modal-content">
            <div class="modal-header">
           
            </div>
            <div class="modal-body">
             <table  class="table">
                 /* Table content display student information */
             </table>
             </div>
    </div>
    </div>
    </div>
    In present situation this modal i can't make it dynamic. I need help to make it dynamic. That means modal display individual student information dynamically.

    Thanks,
    Rima.
    Last edited by cpradio; Oct 9, 2013 at 05:21.

  2. #2
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,411
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    Hi Rima,

    If you only have a small number of rows, the easiest way to do this would be to create a separate modal for each row:

    PHP Code:
    <?php
    foreach ($students as $student) {
    ?>
        <div class="modal fade" id="view-student-<?php echo $student['id'?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
        // rest of the modal html
    <?php
    }
    Note that you need to make the ID of each modal unique (here I'm using the student record ID).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •