1

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 ?

Tharindu Thisarasinghe
  • 3,846
  • 8
  • 39
  • 70
  • 1
    What have you tried so far? Bearing in mind the Bootstrap docs **has a section on exactly this scenario:** http://getbootstrap.com/javascript/#modals-related-target – Martin Bean Apr 23 '15 at 12:04
  • Thank you..!!! The documentation you mentioned was really helpful and I managed to do it. Thanks again!!! – Tharindu Thisarasinghe Apr 23 '15 at 13:57
  • I've been testing the model and it's working great.!!! Anyway, I'm little bit stuck in when trying to call a PHP function with the argument passed via `data-whatever` attribute. I created the link like this. `Text` And I can grab that value using **bind in** js. But, how can I use that value as an argument when calling a PHP function inside the model ? – Tharindu Thisarasinghe Apr 23 '15 at 17:23
  • 1
    That’s outside the scope of discussing in comments. Please ask another question if you have another query. – Martin Bean Apr 23 '15 at 17:38

1 Answers1

1

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');
    });
});
Community
  • 1
  • 1
Narendrasingh Sisodia
  • 21,247
  • 6
  • 47
  • 54
  • I've been testing the model and it's working great.!!! Anyway, I'm little bit stuck in when trying to call a PHP function with the argument passed via data-whatever attribute. I created the link like this. Text And I can grab that value using bind in js. But, how can I use that value as an argument when calling a PHP function inside the model ? – Tharindu Thisarasinghe Apr 23 '15 at 17:25