dsmnedc798226 2010-12-17 10:37
浏览 64
已采纳

ODBC,PHP while循环将数据分配给数组

I want to loop though my query and assign each data field to an array.

 $query ="SELECT * FROM Reservations WHERE Room_ID = '145' ";

    $result = odbc_exec($connect,$query);
     while(odbc_fetch_row($result)){
      $reservation = odbc_result($result, 1);
      $reservation2 = odbc_result($result, 2);
      $reservation3 = odbc_result($result, 3);
      $reservation4 = odbc_result($result, 4);

     }

What I am trying to do is

$content = array(); 
while($info = mysql_fetch_array($result))
{
$content[] = $info;
}

I guess I could check to see the total number of rows and then just do a for loop that increments the $result.

  • 写回答

1条回答 默认 最新

  • doudou5101 2010-12-17 10:44
    关注

    I think you're looking for odbc_fetch_array.

    while ($info = odbc_fetch_array($result)) {
        $content[] = $info;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部