Darkmatter5 Posted July 29, 2008 Share Posted July 29, 2008 Why would $row=mysql_fetch_assoc($result); echo "<table width='650' border='0'>"; echo "<tr>"; echo "<td colspan='2' class='row_description' align='left'>"; echo "<ol>"; while($row) { echo "<li><a href='editjobs.php?=" .$row['job_id']. "' >" .$row['job_number']. "</a>, " .$row['job_desc']. "</li>"; } echo "</ol></td></tr></table>"; create an endless loop that prints out the <li> line endlessly, while echo "<table width='650' border='0'>"; echo "<tr>"; echo "<td colspan='2' class='row_description' align='left'>"; echo "<ol>"; while($row=mysql_fetch_assoc($result)) { echo "<li><a href='editjobs.php?=" .$row['job_id']. "' >" .$row['job_number']. "</a>, " .$row['job_desc']. "</li>"; } echo "</ol></td></tr></table>"; only outputs the specified results and the loop ends correctly? Link to comment https://forums.phpfreaks.com/topic/117169-endless-loop-help/ Share on other sites More sharing options...
Guardian-Mage Posted July 29, 2008 Share Posted July 29, 2008 $row=mysql_fetch_assoc($result); echo "<table width='650' border='0'>"; echo "<tr>"; echo "<td colspan='2' class='row_description' align='left'>"; echo "<ol>"; while($m = $row) { echo "<li><a href='editjobs.php?=" .$m['job_id']. "' >" .$m['job_number']. "</a>, " .$m['job_desc']. "</li>"; } echo "</ol></td></tr></table>"; Link to comment https://forums.phpfreaks.com/topic/117169-endless-loop-help/#findComment-602657 Share on other sites More sharing options...
TempleDMDKrazd Posted July 29, 2008 Share Posted July 29, 2008 because the first one while($row) { } is always TRUE!!! it stays on the first row....you're not fetching any new rows in that loop... try print_r($row); // it should give the same variables over and over and the second one...after it finishes the loop body it goes back to the while condition and $row is assigned a new one...when there arent any more rows mysql_fetch_assoc() return false... Link to comment https://forums.phpfreaks.com/topic/117169-endless-loop-help/#findComment-602658 Share on other sites More sharing options...
Darkmatter5 Posted July 29, 2008 Author Share Posted July 29, 2008 Guardian-Mage, I tried your idea and I got the same result. TempleDMDKrazd, Can you include the print_r($row) code in my code so I know exactly what you mean. I've tried a few things, but it didn't seem to work? Thanks for the replies! Link to comment https://forums.phpfreaks.com/topic/117169-endless-loop-help/#findComment-602675 Share on other sites More sharing options...
samshel Posted July 29, 2008 Share Posted July 29, 2008 $row=mysql_fetch_assoc($result); echo "<table width='650' border='0'>"; echo "<tr>"; echo "<td colspan='2' class='row_description' align='left'>"; echo "<ol>"; while($m = $row) { echo "<li><a href='editjobs.php?=" .$m['job_id']. "' >" .$m['job_number']. "</a>, " .$m['job_desc']. "</li>"; } echo "</ol></td></tr></table>"; even this is endless. try this.. echo "<table width='650' border='0'>"; echo "<tr>"; echo "<td colspan='2' class='row_description' align='left'>"; echo "<ol>"; while($row=mysql_fetch_assoc($result) { echo "<li><a href='editjobs.php?=" .$m['job_id']. "' >" .$row['job_number']. "</a>, " .$m['job_desc']. "</li>"; } echo "</ol></td></tr></table>"; Link to comment https://forums.phpfreaks.com/topic/117169-endless-loop-help/#findComment-602677 Share on other sites More sharing options...
TempleDMDKrazd Posted July 29, 2008 Share Posted July 29, 2008 $row=mysql_fetch_assoc($result); while($row) { print_r($row); //this should print the same thing over and over because its the same row you are not fetching any new rows } Link to comment https://forums.phpfreaks.com/topic/117169-endless-loop-help/#findComment-602678 Share on other sites More sharing options...
TempleDMDKrazd Posted July 29, 2008 Share Posted July 29, 2008 to make the first one work is very simple.. $row=mysql_fetch_assoc($result); echo "<table width='650' border='0'>"; echo "<tr>"; echo "<td colspan='2' class='row_description' align='left'>"; echo "<ol>"; while($row) { echo "<li><a href='editjobs.php?=" .$row['job_id']. "' >" .$row['job_number']. "</a>, " .$row['job_desc']. "</li>"; $row=mysql_fetch_assoc($result); // just add this inside the loop } echo "</ol></td></tr></table>"; add this line inside the while loop which i did for you $row=mysql_fetch_assoc($result) Link to comment https://forums.phpfreaks.com/topic/117169-endless-loop-help/#findComment-602682 Share on other sites More sharing options...
Darkmatter5 Posted July 29, 2008 Author Share Posted July 29, 2008 Excellent TempleDMDKrazd!! Add that one line did the trick!! Thank you! Link to comment https://forums.phpfreaks.com/topic/117169-endless-loop-help/#findComment-602692 Share on other sites More sharing options...
d.shankar Posted July 29, 2008 Share Posted July 29, 2008 Click "Topic Solved" please. Link to comment https://forums.phpfreaks.com/topic/117169-endless-loop-help/#findComment-602785 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.