将变量发送到Bootstrap模式

Here is my php function:

 function displayrecords(){
 $sql = "SELECT * FROM mytable";
 $QueryResult = @mysql_query($sql) or die (mysql_error());
 // more code...

At this point, the function prints out the retuned data in a table:

 echo "<table class='table table-striped table-bordered table-hover'>
";
 while(($Row = mysql_fetch_assoc($QueryResult)) !== FALSE) {

And here is where the issue begins:

 echo "<tr><td><a class=\"open-EditRow btn btn-primary btn-mini\" 
   data-toggle=\"modal\" href=\"myEditModal\" id=\"".$Row[pk_tId]."\" 
   title=\"Edit this row\" \">Delete/Edit</a></td>";

There are more printed td tags after this, but the issue is transferring the id to the modal window. I was told this could be done with straight php and without javascript or ajax.

This is what the code looks like in the modal:

 <div class="modal hide fade" id="myEditModal" tabindex="-1" role="dialog" 
  aria-labelleby="myModalLabel" aria-hidden="true">
 <div class="modal-body">
 <?php
   $id = "<input type=\"text\" name=\"groupId\" id=\"groupId\" value=\"\" />";
   $sql = "SELECT resgroup FROM restable WHERE pk_tId = '" . $id . "'";
   $result = mysql_query($sql);

As you will notice, the $sql is reading $id as an input tag, and therefore, it cannot find the id in the database, and thus returns nothing. I know it starts with the anchor tag inside the echoed table above.

I need to utilize a $_GET (or POST) in the anchor tag, but I do not know where to put it. I'm guessing it should go in the id=\"".$Row[pk_tId]."\" , but how when php is already being used in that id?

I am a visual person, so if you could provide an example, I would be grateful.

You will need a bit javascript to manipulate your modal depends on which button you clicked. I think this solution will help you.

First, I supposed that there is a form inside your modal and you will submit it with your selected id. The modal body should be like this:

<div class="modal-body">
  <form action="//your/path/to/php" method="post">
    <input type="hidden" name="selected_id" id="selected_id" />
    <input type="submit" name="commit" value="Confirm your action?" />
  </form>
</div>

Second, I think your should remove the data-toggle property from your buttons, add another data-* property to hold your id and use explicit javascript call to show your modal with a bit update.

A button should be echo like this

echo "<tr><td><a class=\"open-EditRow btn btn-primary btn-mini\" data-id=\"".$Row[pk_tId]."\" title=\"Edit this row\" \">Delete/Edit</a></td>";

The javascipt

$('.open-EditRow').click(function(){
   var selected_id = $(this).attr('data-id');
   $('#myEditModal #selected_id').val(selected_id);
   $('#myEditModal').modal('show');
});

Now, in the php file declared inside the form in the modal - which receives your post data, you can var_dump the $_POST.