dongren1986 2013-04-17 12:45
浏览 13

为什么这个代码行中的零

I have found a reference in the tutorials that this 0 returns the first row but I "Don't Get It" What if there's more than 1 row such as in the function below?? (ie: I have a table of 200 users and this column "UsersName" is just one among 10 others so why the Zero?)

Could someone please spell out why this 0 is in this line of code??

Thanks

function member_count() {
    return mysql_result(mysql_query("SELECT COUNT(`UsersName`) FROM `users` WHERE `Active` = 1"), 0);
}
  • 写回答

3条回答 默认 最新

  • dpjw67160 2013-04-17 12:47
    关注

    Couldn't you have looked up the PHP documentation? It's rather good...

    string mysql_result ( resource $result , int $row [, mixed $field = 0 ] )
    

    row

    The row number from the result that's being retrieved. Row numbers start at 0.

    http://php.net/manual/en/function.mysql-result.php

    Imagine you done a SELECT * FROM users, where the table contains

    name  | age
    David | 29
    John  | 18
    Paul  | 26
    

    Row 0 would be "David - 29", row 1 would be "John - 18", so forth.

    评论

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真