doutuo1939 2011-09-06 23:39
浏览 36

使用分页输出数组

this is my code

//select all the members id
$result = mysql_query("select id from member");

//create array of ids
$id = array();

// page is the number of my pagination numbering and its from 1 to 10
$dis = $page;// for example $page = 1

// $page get its value every time a user click my pagination numbering i.e $page = $_GET[page]; 
// guess you understand

while($u_id = mysql_fetch_assoc($result)){
    //id is my field name
    $id[] = $u_id[id];
}

echo $id[$dis];

my problem is that this above code works for only 4 records out of 10records. my question is, why is it not working outputin other ids when the array index is 4,5... and howw do i amke it work

secondly the echo part is just the test of my idea but what i wanted to do is to pass the return id to a function for query. please any help

  • 写回答

3条回答 默认 最新

  • dongshuo2752 2011-09-06 23:44
    关注

    Well not sure if this is your problem but you might want to correct this if its not just a type in your post:

    while($u_id = mysql_fetch_assoc($result)){
    $id[] = $u_id['id']; // this should be 'id' not $id
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路