duanhong8839 2012-05-04 21:27
浏览 44

从mysql加载数组数组

Basically I want to take 4 of the 16 columns; id,username,country,signupdate; in my table and make an array of arrays out of them.

mysql table

I have a basic grasp on the concept, grab a row and place in an array, then the next one, and so on. then put the arrays in an array.

Only one problem. I have absolutely no idea how to do this. I just started learning in php and mysql, so please be patient. Thanks in advance!

  • 写回答

1条回答 默认 最新

  • download201401 2012-05-04 21:32
    关注

    It should do that automatically for you:

    $query = mysql_query("SELECT `id`,etc");
    while( $row = mysql_fetch_assoc( $query ) )
    {
      echo $row['id'];
      echo $row['etc'];
    }
    

    That will give you each row of your 'associative array'. Or, you can make a big associative array:

    $bigArray = array();
    $query = mysql_query("SELECT `id`,etc");
    while( $row = mysql_fetch_assoc( $query ) )
    {
      $bigArray[] = $row;
    }
    
    print_r($bigArray);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)