dongmei1911 2015-07-06 10:27
浏览 23
已采纳

每次访问时从数据库发送不同的数据

The app which i am making is going to run on 8 android devices at a time and when the first device runs app i.e fetches the data from web service it should give it the data of 1st ten fields from the data base.

when any other user wants it should give the data of next 10 fields etc but how can i implement this in php web service when i use Limit $i,10 then i initialize $i=0 in the start of web service and the issue is that whenever any user access the web service the same web service code executes i mean that the $i is again reset to 0 in the start what should i do?

I want the when the webservice first access the database the start 10 fileds data is given to it and even ever it accessess the database again the next 10 fields data is given to it and so on...

this is my php webservice code

 $i=0;
  $q=mysql_query("SELECT * FROM users1 where status='failed' OR    status='ready' LIMIT $i,10  ");
  while($row=mysql_fetch_assoc($q))
  $json_output[]=$row;   
 echo json_encode($json_output);
  • 写回答

2条回答 默认 最新

  • drozwmi5440 2015-07-06 10:39
    关注

    From the android side you could add a flag in the url to know what the client requires. For example,

    If client needs first 10 fields, he could call

    http://your.url.com/code.php?offset=0

    if he needs the later, he would call

    http://your.url.com/code.php?offset=10

    You could get the value of offset in your php file using $offset = $_GET['offset']; Then you could run the query desired by the client.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度