dongxi9326 2017-04-11 06:04
浏览 19
已采纳

如何显示具有特定限制数据的数据库中的数据?

hi guy's i need help from you.. i have a problem while selecting data from database with a specific limit data that i need to show or display. i want to display data between 40 to 80 but when the data displaying, the data that showing is from 40 to 81( and it can reach more of 81). i use this function to select that data.

<?php
$con=mysqli_connect("localhost","root","","silo");

if (!$con) {
  die('Could not connect: ' . mysql_error());
}


// Data for Titik1
$query = mysqli_query($con,"SELECT * FROM temp2 LIMIT 40, 78");
$rows = array();

while($tmp= mysqli_fetch_assoc($query)) {
    $rows[] = $tmp;
}

echo json_encode($rows);
mysqli_close($con);
?> 
  • 写回答

1条回答 默认 最新

  • dtzjvj3915 2017-04-11 06:17
    关注

    Your query needs some corrections. Go through this tutorial for more details: https://www.w3schools.com/php/php_mysql_select_limit.asp

    If you want to get records from 40 to 80 then your query should be:

    SELECT * FROM temp2 LIMIT 39, 41
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀