All functions work every time except the "btn_replay" which only works on the first iteration.
It does not use the session variable
File name is add_hock_query_js.php and is included in file ad_hoc_query.php
I have scoured the internet without a result and am stuck.
<?php session_start(); ?>
<script type="text/javascript">
$(document).ready(function(){
$('input#btn').hide();
$('#btn_clear, #btn_reset,#btn_save, #div_sql').hide();
$('textarea[id="text"]').mouseover(function(){
var xs = $(this).val();
var xs = xs.substring(0, 6);
if (xs == 'select') {
$('input#btn, #btn_save').show();
} else {
$('input#btn, #btn_save').hide();
}
});
$("#btn_reset").click(function () {
var d = "select * from " ;
$("#text").val(d);
$('input#btn, #btn_save').hide();
});
$("#btn_clear").click(function () {
var d = "" ;
$("#text").val(d);
$('input#btn, #btn_save').hide();
});
$("#btn_save").click(function () {
var d = $('#text').val();
values = { "ad_hoc_query": d };
$.post("../inc/set_sessions.php", $.param(values));
});
$("#btn_replay").click(function() {
var q = '<?php echo $_SESSION["ad_hoc_query"]; ?>';
$("#text").val(q);
$('input#btn').show();
});
$("#input_db").click(function () {
var d = $(this).val();
values = { "ad_hoc_db": d};
$.post("../inc/set_sessions.php", $.param(values));
$('#div_sql, #btn_clear, #btn_reset').show();
});
});
</script>
File set_sessions.php
<?php session_start();?>
<?php
foreach($_REQUEST as $key => $value)
{
$_SESSION[$key] = $value;
}
?>