gpt4 book ai didi

php - 使用 php jquery ajax 从数据库获取仪表板计数

转载 作者:行者123 更新时间:2023-11-29 10:48:28 27 4
gpt4 key购买 nike

我正在尝试使用 PHP、jQuery 和 AJAX 从数据库获取数据计数到 HTML div,但下面的代码不起作用。

我刚开始学习ajax,请帮忙。谢谢!

enter image description here

index.php

            <div class='col-lg-3 col-md-6'>
<div class='panel panel-primary'>
<div class='panel-heading'>
<div class='row'>
<div class='col-xs-3'>
<i class='fa fa-microphone fa-5x'></i>
</div>
<div class='col-xs-9 text-right'>
<!-- here i want to fetch result -->
<div id="leadmonth"></div>
<div>Total Leads</div>
</div>
</div>
</div>
</div>
</div>

Jquery

$(document).ready(function() {

$.ajax({
type:'POST',
url:'php_action/resourceqareportdashboardcount.php',
dataType : 'json',
success:function(html){
$('#leadmonth').html(html);
}

});

PHP

<?php
// This Month Count
require_once 'db_config.php';
$output= '';
$sql = "SELECT * FROM leads WHERE YEAR(leadcreationdate) = YEAR(NOW()) AND MONTH(leadcreationdate)=MONTH(NOW())";
$query = $connect->query($sql);
$totalleads = mysqli_num_rows($query);

if ($monthtotalleadscount > "0") {
$output = "<div class='huge'>$totalleads</div>";
} else {
$output = "<div class='huge'>0</div>";
}

// database connection close
$connect->close();

echo json_encode($output);

最佳答案

$(document).ready(function() {

$.ajax({
type:'POST',
url:'php_action/resourceqareportdashboardcount.php',
// dataType : 'json',
success:function(html){
$('#totalleadsmonth').html(html);
}
});

});

关于php - 使用 php jquery ajax 从数据库获取仪表板计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44160630/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com