I have a php here
<?php
/* Initiate Connection */
require 'conn.php';
/* Filter Criteria */
$startdate = $_POST['startdate'];
$enddate = $_POST['enddate'];
$fsp = $_POST['fsp'];
/* Queries */
$query = 'MYSQL Query Here';
/* Generate Whole Sales Report */
$rs = mysqli_query($con,$query);
/* Sales Summary */
while ($array_data = mysqli_fetch_row($rs)) {
$data[] = $array_data;
}
/* Output */
echo json_encode($data);
?>
This php code outputs a data from mysql in a form of rows and columns. my question is this but before that here is my code when passing the data in a php file.
$(document).ready(function() {
$('#btngenerate').click(function(e) {
$.ajax({
url: 'gen_report.php',
type: "POST",
datatype: 'json',
data: {
startdate: 'Data',
enddate: 'Data',
fsp: 'Data'
},
success:
function(data) {
});
});
});
My question here is can someone lead me in the right path? My target here is to create a format or set of codes using this codes that I can recycle. I mean use it anywhere like passing data to php retreive it and so on.
My target here is what If my myphp file is composed of multiple queries and json_encode which is where? I means json_encode1 = html_table1,json_encode2 = html_table2 and so on how can I achieve it?
TYSM
$return=array("table1"=>$data1, "table2"=>$data2)then json_encode that and send it back.