为什么再次出现这种情况(mysqli

编程入门 行业动态 更新时间:2024-10-10 05:16:23
本文介绍了为什么再次出现这种情况(mysqli_num_rows()需要参数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个名为tbl_video的表,它由两个字段组成(video_id,video_title我希望使用像社交网站一样的Ajax JQuery添加一个加载按钮。我能够获得前四个记录但是当我试图获得时然后我才得到这个例外。我做错了什么。 我尝试了什么:

I have a table named tbl_video that consist of two fields (video_id, video_title What I want to add a load more button using Ajax JQuery like social networking sites .I am able to get the first four records but when I try to get the othersthen I am getting this exception .What am i doing wrong . What I have tried:

this my index.php file I create table structure here and then fetch records. <pre lang="php"> <pre> <table class="table table-bordered" id="load_data_table"> <thead> <tr> <td width="15%">Video Id</td> <td>Video Title</td> </tr> </thead> <?php while ($row = mysqli_fetch_array($result)) { $video_id = $row['video_id']; ?> <tr> <td><?php echo $row['video_id']; ?></td> <td><?php echo $row['video_title']; ?></td> </tr> <?php } ?> <tr id="remove_row"><td><button type="button" class="more btn btn-success form-control" data-id="<?php echo $video_id; ?>">More</button></td></tr> </table> </div>

<script> function moreButton(){ $('.more').click(function(){ var id=$(this).data("id"); $.ajax({ url:"more.php", data:{id:id}, method:"post", success:function(data){ if(data!=''){ $('#load_data_table').append(data); $('#remove_row').remove(); moreButton(); } else{ $('.more:last').html("No Data"); } } }); }); } $(document).ready(function(){ moreButton(); });

and this the more.php file.I think it is self explanatory

<?php ini_set('display_errors', 1); $id = $_POST['id']; $output = ''; $db = mysqli_connect('localhost', 'root', '', 'testing'); $data = mysqli_query($db, "select * from tbl_video where video_id >{$id} limit 2"); if (mysqli_num_rows($data)) { while ($row = mysqli_fetch_array($data)) { $output .= ' <tbody> <tr> <td>'.$row['video_id'].'</td> <td>'.$row['video_title'].'</td> </tr> '; } $output .= '<tr id="remove_row"><td><button type="button" class="more btn btn-success form-control" data-id="'.$row['video_id'].'">More</button></td></tr></tbody>'; echo $output; }

任何帮助都会被评估。

any help would be appriciated.

推荐答案

row = mysqli_fetch_array( row = mysqli_fetch_array(

result)){

video_id = video_id =

更多推荐

为什么再次出现这种情况(mysqli

本文发布于:2023-10-27 23:54:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534901.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:这种情况   mysqli

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!