I am converting a PHP application from MySQL to PostgresSQL. The MySQL works flawlessly. The database for this application is a one to many relationship. I have a while loop nested inside another while loop
<?php while ($movie_row = pg_fetch_array($movie, PGSQL_ASSOC)) { ?>
[html code to echo various elements of $movie_row]
[a record in this part will have multiple records of information
from another table in the db which the following code will
fetch and process]
<?php $movie_file_result = pg_query ($conn, "SELECT DISTINCT(cd_name)
FROM movie_files
WHERE data_id=".$movie_row[id]."
ORDER BY cd_name");?>
<div class="files">
<p>Find in:</p>
<ul class="file_list">
<?php while ($filesrow = pg_fetch_array($movie_file_result, PGSQL_ASSOC)) { ?>
PROBLEM RESIDES HERE (see below)
<li class="cd_name">
<?php echo $filesrow[cd_name]."\n" ?>
</li>
<?php }?>
[remainder of html code to iterate elements of $movie_row]
<?php }?>
For the nested while using $filesrow an infinite loop happens. Debugging in Netbeans sometimes the infinite loop happens only on the second while loop. Other times, I get a page full of the first layer while loop.