I've seen multiple pages regarding my issue. The closest I found was this:
Passing data to a bootstrap modal
But I think my issue is slightly different. I have pulled MySQL data and displayed it within a table via PHP. I need to pull the row data via href into a bootstrap modal page.
On my edit.php page, here is the first line of the returned data, where the EDIT button and href is located:
echo "<tr><td><a class=\"btn btn-primary btn-mini\" data-toggle=\"modal\" href=\"#myEditModal\" data-project-id=\"$Row[pk_tId]\">Delete/Edit</a></td>";
Please disregard the lack of closing tags. It's in the code, just not displayed here.
I'm guessing I need to get $Row[pk_tId]
and pass that into the modal, and then run a MySQL statement off pk_tId so that I can pull the data into the modal input fields. My question is: How do I do that? I would like to just use javascript. No ajax for now. I'll learn that later.
So please, how do I get $Row[pk_tId]
into the modal shown here:
<div class="modal hide fade" id="myEditModal" tabindex="-1" role="dialog" aria-labelleby="myModalLabel" aria-hidden="true">
<form class="well-small" action="edit.php" method="POST" id="modalForm" name="modalForm">
<?php
if (isset($_GET['pk_tId'])){
$id = $_GET['pk_tId'];
$res = mysql_query("SELECT * FROM mytable WHERE pk_tId ='" .$id. "'");
$selection = mysql_fetch_array($res);
}
?>
<label>Group</label>
<input type="text" id="group" name="group" value="<?php echo $selection[mygroup]; ?>" />
Please disregard the closing form tags. They are there. I just didn't want to display a lot of unnecessary code.