Php 根据“加载更多按钮值”;其中;克隆条件

Php 根据“加载更多按钮值”;其中;克隆条件,php,jquery,mysql,ajax,Php,Jquery,Mysql,Ajax,我使用LoadMore按钮从同一网页上特定id的数据库中加载内容。代码如下: <div class="postList col-lg-12"> <legend><h1 style="color:#298208;">Savings Bucks Details</h1> </legend> <?php $busi_id = mysqli_real_escape_string($conn, $_SESSION['bus

我使用LoadMore按钮从同一网页上特定id的数据库中加载内容。代码如下:

<div class="postList col-lg-12">
     <legend><h1 style="color:#298208;">Savings Bucks Details</h1> </legend>
<?php
    $busi_id = mysqli_real_escape_string($conn, $_SESSION['busi_id']);

    if (isset($busi_id)) {
        $query = "SELECT * FROM savingsbucks_business WHERE busi_id='$busi_id' ORDER BY sbb_id DESC LIMIT 2";
        $result = mysqli_query($conn, $query) or die('Query failed: ' . mysqli_error($conn));
        $numrows_savingsbucks = mysqli_num_rows($result);

    if ($numrows_savingsbucks == '0') {
        echo "<p style='text-align:center; color:#ff4400; margin-top:40px;'>No Data available!</p>";
    } else {
 ?>

<div class="table-responsive">
    <table border="1" class="table table-bordered">
        <thead>
        <th class="consumer_point_text">Shop ID</th>
        <th class="consumer_point_text">SenderID</th>
        <th class="consumer_point_text">Busi ID</th>
        <th class="consumer_point_text">Customer Type</th>
        <th class="consumer_point_text">Customer Name</th>
        <th class="consumer_point_text">Customer Email</th>
        <th class="consumer_point_text">Customer Phone</th>
        <th class="consumer_point_text">Two</th>
        <th class="consumer_point_text">Five</th>
        <th class="consumer_point_text">Ten</th>
        <th class="consumer_point_text">Twenty</th>
        <th class="consumer_point_text">Fifty</th>
        <th class="consumer_point_text">Hundred</th>
        <th class="consumer_point_text">Five Hundred</th>
        <th class="consumer_point_text">Total Savings Bucks</th>

    </thead>
<?php if($numrows_savingsbucks > 0){
    while ($row = mysqli_fetch_array($result)) {
        $sbb_id = $row['sbb_id'];
        $sender_id = $row['sender_id'];
        $busi_id = $row['busi_id'];
        $type = $row['type'];
        $consu_name = $row['consu_name'];
        $consu_email = $row['consu_email'];
        $consu_phone = $row['consu_phone'];
        $two = $row['two'];
        $five = $row['five'];
        $ten = $row['ten'];
        $twenty = $row['twenty'];
        $fifty = $row['fifty'];
        $hundred = $row['hundred'];
        $five_hundred = $row['five_hundred'];
        $total_two += $two;
        $total_five += $five;
        $total_ten += $ten;
        $total_twenty += $twenty;
        $total_fifty += $fifty;
        $total_hundred += $hundred;
        $total_five_hundred += $five_hundred;
        $total_bucks = $two+$five+$ten+$twenty+$fifty+$hundred+$five_hundred;
        $grand_total += $total_bucks;
?>

    <tr>
        <td class="consumer_point_text"><?=$sbb_id?></td>
        <td class="consumer_point_text"><?=$sender_id?></td>
        <td class="consumer_point_text"><?=$busi_id?></td>
        <td class="consumer_point_text" style="text-transform:capitalize;"><?=$type?></td>
        <td class="consumer_point_text"><?=$consu_name?></td>
        <td class="consumer_point_text"><?=$consu_email?></td>
        <td class="consumer_point_text"><?=$consu_phone?></td>
        <td class="consumer_point_text"><?=$two?></td>
        <td class="consumer_point_text"><?=$five?></td>
        <td class="consumer_point_text"><?=$ten?></td>
        <td class="consumer_point_text"><?=$twenty?></td>
        <td class="consumer_point_text"><?=$fifty?></td>
        <td class="consumer_point_text"><?=$hundred?></td>
        <td class="consumer_point_text"><?=$five_hundred?></td>
        <td class="consumer_point_text"><?=$total_bucks?></td>
    </tr>

<?php } ?>      
</table>

<div class="show_more_main" sbb_id="show_more_main<?php echo $sbb_id; ?>">
    <span sbb_id="<?php echo $sbb_id; ?>" class="show_more" title="Load more posts">Load more</span>
    <span class="loding" style="display: none;"><span class="loding_txt">Loading...</span></span>
</div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script
<script src="http://demos.codexworld.com/includes/js/bootstrap.js"></script>

<script type="text/javascript">
    $(document).ready(function(){
    $(document).on('click','.show_more',function(){
    var ID = $(this).attr('sbb_id');
    $('.show_more').hide();
    $('.loding').show();
    $.ajax({
        type:'POST',
        url:'ajax_more_business_shop.php',
        data:'sbb_id='+ID,
        success:function(html){
            $('#show_more_main'+ID).remove();
            $('.postList').append(html);
            }
        });
    });
});
</script>

<?php }  ?> 
</div> <!-- ./col-lg-12 -->
<?php } }?>

储蓄详情
我刚刚将“busi_id”传递到Ajax页面。。。使用“加载更多”按钮

<div class="show_more_main" ds_id="show_more_main<?php echo $ds_id; ?>">
    <span ds_id="<?php echo $ds_id; ?>" busi_id="<?php echo $busi_id; ?>" class="show_more" title="Load more posts">Load more</span>
    <span class="" style="display: none;"><span class="loding_txt">Loading...</span></span>
</div>

您的代码易受SQL注入攻击。你应该使用事先准备好的陈述。@Dharman,我来这里的目的,请你帮忙。。拜托?有人会帮我或建议我吗?
<div class="show_more_main" ds_id="show_more_main<?php echo $ds_id; ?>">
    <span ds_id="<?php echo $ds_id; ?>" busi_id="<?php echo $busi_id; ?>" class="show_more" title="Load more posts">Load more</span>
    <span class="" style="display: none;"><span class="loding_txt">Loading...</span></span>
</div>
<script type="text/javascript">
    $(document).ready(function(){
    $(document).on('click','.show_more',function(){
    var ID = $(this).attr('ds_id');
    var Busi_id = $(this).attr('busi_id');

    $('.show_more').hide();
    $('.loding').show();
    $.ajax({
        type:'POST',
        url:'ajax_more_consumer_shop.php',

        data: {
            'ds_id': ID,
            'busi_id': Busi_id
            },


        success:function(html){
            $('#show_more_main'+ID).remove();
            $('.postList').append(html);
        }
    });
});
$query = "SELECT COUNT(*) as num_rows FROM savingsbucks_business WHERE ds_id < ".$_POST['ds_id']." AND busi_id=".$_POST["busi_id"]." ORDER BY ds_id DESC";
$result = mysqli_query ($conn, $query);
$row = mysqli_fetch_assoc($result);
$totalRowCount = $row['num_rows'];
$showLimit = 2;

$query = "SELECT * FROM savingsbucks_business WHERE ds_id < ".$_POST['ds_id']." AND busi_id=".$_POST["busi_id"]." ORDER BY ds_id DESC LIMIT $showLimit";
$result = mysqli_query ($conn, $query);
$rowcount=mysqli_num_rows($result);