$link = mysqli_connect("localhost", "root", "", "direct_power");
$sql = "select * from table_1";
$result = mysqli_query($link, $sql);
$arr = array();
$mon = array();
while($rows = mysqli_fetch_array($result))
{
$arr[] = $rows;
}
//header('Content-type: application/json');
//$arr[] = $rows;
$mon = ['about'=>'compnany','detail'=>$arr,'days'=>array('monday','tuesday','wednesday','thirsday')];
echo json_encode($mon,JSON_PRETTY_PRINT);
exit();
//Ajax jquery code
function test()
{
var form_data = $('#frm1').serializeArray();
console.log(form_data);
$.ajax({
type: "POST",
data: {
form_data:form_data
},
url: '../controller/table1_handller.php',
success: function(data) {
console.log(data);
var x = JSON.parse(data);
//console.log(x[0].name);
//console.log(Object.keys(x ).length); // to cont json size pass only "parsed variable " here like 'x' not "data"
$.each(x.detail, function (index, value) {
$("#roll_no").prepend(value['name']);
});
$.each(x.days, function (index, value) {
$("#days").prepend(value);
});
}
});
$sql = "select * from table_1";
$result = mysqli_query($link, $sql);
$arr = array();
$mon = array();
while($rows = mysqli_fetch_array($result))
{
$arr[] = $rows;
}
//header('Content-type: application/json');
//$arr[] = $rows;
$mon = ['about'=>'compnany','detail'=>$arr,'days'=>array('monday','tuesday','wednesday','thirsday')];
echo json_encode($mon,JSON_PRETTY_PRINT);
exit();
//Ajax jquery code
function test()
{
var form_data = $('#frm1').serializeArray();
console.log(form_data);
$.ajax({
type: "POST",
data: {
form_data:form_data
},
url: '../controller/table1_handller.php',
success: function(data) {
console.log(data);
var x = JSON.parse(data);
//console.log(x[0].name);
//console.log(Object.keys(x ).length); // to cont json size pass only "parsed variable " here like 'x' not "data"
$.each(x.detail, function (index, value) {
$("#roll_no").prepend(value['name']);
});
$.each(x.days, function (index, value) {
$("#days").prepend(value);
});
}
});
No comments:
Post a Comment