0

I have a list created dinamically using php

while($row = $result->fetch_assoc()){ //$row is a row fetched from my database
<tr>
   <td><?php echo $row['id']?></td>
   <td><?php echo $row['name']?></td>
   <td><?php echo $row['surname']?></td>
   <td><a href="#Modal" <?php echo "id= " . $row['username'] ?> class="btn btn-small btn-info" data-toggle="modal" > Vedi</a></td>
</tr>
}

Modal is something like this:

<div id="Modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true">
      <div class="modal-header">
        <a class="close" data-dismiss="modal" aria-hidden="true">×</a>
        <h3 id="myModalLabel">user information</h3>
      </div>
      <div class="modal-body" id="loadInfo">
        <div class="row-fluid">
          <div class="span12">

         <!-- my php code here -->

        </div>
       </div>
     </div>
</div>

My php code must be referred to a precise user. So I need that the Modal can receive this the id of the in order to execute the proper php code.

How can I obtain this result?

3
  • set a jQuery click handler on the links that updates whatever it is you want in the modal. Can't run php in browser so not entirely clear what your expectations are Commented May 4, 2013 at 16:09
  • @Joseph82 I am facing the same problem, I am a newbie and don't know how to implement it. I got a dynamic list but when I display it in modal using youtube iFrame, then only the first video is played rest are not. Can you please share the code so that I can get help from that. Thanks in advance. Commented Sep 21, 2014 at 5:56
  • Make sure you give your modal a dynamic id. in a php query while loop set the modal id to your query row id for example. i just answered essentially the same question here stackoverflow.com/questions/28081592/… If you want, i would be happy to write you both what you need. Commented Jan 22, 2015 at 5:38

1 Answer 1

1

assign the values of the user info to javascript variables. Add a data attribute to the modal toggle buttons like data-user_id=<?php echo $row['id']; ?> and make a jquery click handler to update the modal's content to match the button you clicked.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.