In an index.php file I have a table and using the following script that takes two variables that I need to assign to a query:
$('#table tbody').on( 'click', 'td', function () {
name = $(this).parent().find('td').html().trim();
stat = $('#table thead tr th').eq($(this).index()).html().trim();
});
In the table, once I select a value from a cell, a modal window is opened that shows some data when making a second query (now I have the variables set):
<div class="modal fade" id="add_new_record_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Tickets</h4>
</div>
<div class="modal-body">
<?php
include("conn.php");
if(isset($_GET['name'])) {
$name = $_GET['name'];
} else {
$name = "user1";
}
if(isset($_GET['stat'])) {
$stat = $_GET['stat'];
} else {
$stat = "open";
}
$result = mysql_query("SELECT 'id', 'city', 'desc' from 'entorno' where 'name' = '$name' and stat = '$stat'");
while($test = mysql_fetch_array($result))
{
$id = $test['id'];
echo"<div class='form-group'>";
echo"<label>".$test['city']." ".$test['desc']."</label>";
echo"</div>";
}
mysql_close($conn);
?>
</div>
</div>
</div>
</div>
I have problems to assign them with what I currently have in this file. What could I do to make jQuery assign the variables to the query?