Denoteone
Denoteone

Reputation: 4055

ODBC, PHP while loop to assign data to array

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.

Upvotes: 1

Views: 9211

Answers (1)

ircmaxell
ircmaxell

Reputation: 165281

I think you're looking for odbc_fetch_array.

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

Upvotes: 6

Related Questions