Tharindu Thisarasinghe
Tharindu Thisarasinghe

Reputation: 3998

Get MySQL data to bootstrap model

I have a list of users on my web page echoed using a PHP loop. The names are links look like this.

<a href="user.php?user={$user['id']}">{$user['username']}</a>

So, when I click on each user, I am taken to user.php page.

user.php displays each user's information based on the query parameter $user['id'] in the URL. Using $_GET['id'] method.

So, that's the current situation I have.

What I now want to do is, display user's information in a Bootstrap Model

So, how could I get that query parameter into the Bootstrap model. And do the same PHP processes to get the same functionality ?

Upvotes: 1

Views: 1173

Answers (1)

Narendrasingh Sisodia
Narendrasingh Sisodia

Reputation: 21422

If you have google this you can get number of results related to it.

Here is code seems to be referred from one of this question passing-data-to-a-bootstrap-modal

HTML

<a data-toggle="modal" data-id="ISBN564541" title="Add this item" class="open-AddBookDialog btn btn-primary" href="#addBookDialog">test</a>

<div class="modal hide" id="addBookDialog">
 <div class="modal-header">
    <button class="close" data-dismiss="modal">×</button>
    <h3>Modal header</h3>
  </div>
    <div class="modal-body">
        <p>some content</p>
        <input type="text" name="bookId" id="bookId" value=""/>
    </div>
</div>

Javascript

$(document).ready(function () {
    $(".open-AddBookDialog").click(function () {
        $('#bookId').val($(this).data('id'));
        $('#addBookDialog').modal('show');
    });
});

Upvotes: 1

Related Questions