Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

odbc_fetch_row doesn't work when it is used multiple times

while(odbc_fetch_row($viewTablo)){
    
          echo "<td>".odbc_result($viewTablo,$inta)."</td>";
          echo "</tr>";     
}

This code works and returns values I expected. But when I use odbc_fetch_row multiple times, just the first one works. What is the reason and how do I prevent this?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It will only fetch as many rows as are present in your query results. Once you run out of rows, it will return false as per the documentation. It does not return the result set’s internal pointer to the beginning of the results.

If you want to loop over the data multiple times you can put it all into a PHP array when you first extract it from the database, and then use the array later on in the script when you need to access it.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading