my program works like this. there are three buttons on html page which are linking to three different php files which result in xml, result are based on fixed sql command in oracle. when user click on one of the button eg.
<p><input class="fetchSeries" type="button" value="CurrValue">
<a href="connectyf.php"> </a>
<span></span>
</p>
it will then trigger the below ajax, and to plot a graph on html page
$("input.fetchSeries").click(function () {
var button = $(this);
var dataurl = button.siblings('a').attr('href');
$.ajax({
url: dataurl,
type: "GET",
cache: false,
success: function (data2) {
$(data2).find('node').each(function(){
var currV = $(this).find('snv').text();
var dateT = ($(this).find('agev').text())*1000;
var d2 = [];
d2.push(dateT, currV);
dataset.push(d2);
button.siblings('span').text('Fetched ' + ', first point: ' );
})
data.push(dataset);
$.plot(placeholder, data,options);
dataset = [];
}
});
});
sql command :
$sql = "SELECT TO_CHAR(DATETIME, 'YYYY-MM-DD HH24:MI:SS') AS DATETIME, PRESENTSTATE
FROM T00000000_01080413 WHERE DATETIME BETWEEN '04-OCT-11' AND '15-OCT-11' ";
what i need to do now is place four user input field and one button, click the button to control the sql command, something should be like this in php page if im not mistaken
$sql = "SELECT TO_CHAR(DATETIME, 'YYYY-MM-DD HH24:MI:SS') AS '$_POST[datetime]', '$_POST[vall]' FROM T00000000_01080413 WHERE DATETIME BETWEEN '$_POST[startdate]' AND '$_POST[enddate]' ";
now im a bit headache how do i use the user input as sql command and plot the graph once i click the button?
is it may use the input[name=startdate]; something like that? soooo headache now.please inspire me.... thx so much in advance
<form method="post" >
<div>
<input type="text" class="form-text required" value="" size="15" id="edit-name" name="startd" maxlength="60">
<input type="text" class="form-text required" value="" size="15" id="edit-name" name="endd" maxlength="60">
<input type="text" class="form-text required" value="" size="15" id="edit-name" name="pname" maxlength="60">
<input type="text" class="form-text required" value="" size="15" id="edit-name" name="val" maxlength="60">
<input class="fetchSeries" type="button" value="draw graph!"/>
</div>
</form>
$.ajax({
type: "POST",
url: "connectyf1.php",
data: "startdate="+startdt+"&enddate="+enddt+"&tablename="+tname+"¶meter"+param,
success: function(grapHtml){
$("#graph").append(graphHtml);
$.ajax({
url: "connectyf1.php",
type: "GET",
cache: false,
success: function (data2) {
$(data2).find('node').each(function(){
var currV = $(this).find('snv').text();
var dateT = ($(this).find('agev').text())*1000;
var d2 = [];
d2.push(dateT, currV);
dataset.push(d2);
button.siblings('span').text('Fetched ' + ', first point: ' );
})
data.push(dataset);
$.plot(placeholder, data,options);
dataset = [];
}
});
}
});