dougan1465 2018-10-15 08:36
浏览 88
已采纳

SQL查询返回有限的结果

Working with WordPress, running a custom query to pull all records relating to a specific condition. When I run the query in phpmyadmin it returns all records, when I run the query through PHP code, only 2-5 results return, need to find out how to resolve this:

// get variables from form page
$txtReg = $_REQUEST['txtReg'];
$txtMsg = $_REQUEST['txtMsg'];

// connect to database
$mydb = new 
wpdb('***','***','***','***');

// run the query to fetch all cell numbers from the region variable
$query = "SELECT * FROM tblusers WHERE `Region` ='$txtReg'";
$rows = $mydb->get_results($query);

// display all cell numbers from that region
foreach ($rows as $row) {
  $txtCell = $row->Cell;
  //doSendSMS($txtCell,$txtMsg);
  echo $txtCell;  
}

E.g there are 100 cell numbers in Region A, only a few are returned and echoed, not all 100 like it should be, so when I run the sms code (which is the actual function, echo is used just to test results), not all receive the sms.

  • 写回答

1条回答 默认 最新

  • donglin9068 2018-11-01 13:03
    关注

    @Caius Jard was correct about the settings in the database, it was in fact limited even though no limit clause was applied in the sql query itself. The code is functional in my setup but was limited by the default settings.

    tested using:
    $query = "SELECT * FROM tblusers WHERE Region ='$txtReg' LIMIT 100";

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line