Any ideas why my query only returns the very last record that matches the criteria specified?? $sql_record ="SELECT * FROM payment_request WHERE status_code = 'P'"; $result_record = mssql_query($sql_record) or die(mssql_error()); if(!empty($result_record)) { while ($row_record = mssql_fetch_array($result_record)) { $id_record = $row_record['id']; } } print_r ($sql_record); The result of the print_r displays only the last record that matches the query criteria. I tried a foreach instead of a while with no luck.