简体   繁体   中英

How to display the detailed data from the database using bootstrep modal codeigniter?

how to display the detailed data from the database based on the ID with modal boostrep twitter, please make it for jquery or ajax code so that the data appears when I click the details into the pop-up modal ?

<tbody id="terakhir" >

                    <?php
                    $iw = $this->uri->segment(3) + 0;
                    foreach ($blogger as $i): $iw++;
                        ?>

                        <tr >
                            <td>  
                                <input type="text" class='nomor' id='<?php echo $iw; ?>'>
                                <input type="text" class='box' >
                                <?php echo $iw; ?></td>
                            <td>
                                <?php echo $i->username; ?>


                            </td>
                            <td class=lastName >
                                <?php
                                $date = strtotime($i->tanggal_register);
                                echo format_date($date, time()) . ' WIB';
                                ?>


                            </td>
                            <td>Member</td>
                            <td>

                                <?php
                                if ($i->akses != "B"):
                                    echo "<span class='label label-success'>Active</span>";
                                else:
                                    echo "<span class='label label-important'>Blokir</span>";
                                endif;
                                ?>

                            </td>

                            <td>

                                <a class="btn btn-danger" href="#">
                                    <i class="fa fa-trash-o "></i> 
                                </a>
                                <a href="#" class="btn tampil<?php echo $iw; ?>">Edit</a>


                            </td>
                        </tr>

                        <?php
                    endforeach;
                    ?>

                </tbody>

Update the username columns as

<td>
   <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" value="<?php echo $i->username;?>"><?php echo $i->username; ?></button>
</td>

Now add this javascript to call the modal and load data in ajax

<script type="text/javascript">
             $("#terakhir").on('click','button',function(event){
        var username = $(this).val();
        $.ajax({
          type: 'POST',
           url: "yourphpfile.php",                  
          data:"username="+username,
       success:function(data){
          //print your data here in modal html elements
        },
       error:function(error){
        alert(error);
        }});
    });
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM