Page 1 of 1

Code after while() loop not executing

Posted: Sun Apr 15, 2007 7:05 pm
by LiveFree
Hey All,

I have this while() loop producing some HTML from some data in the database. However, (and I am sure the query is fine) the code after the while isn't be adding to the variable (as you'll see in the code). Even though the variable isn't being added on to after the loop, the site still renders and works fine otherwise.

Any thoughts?

Code: Select all

$projectlist = '<td width="37" height="361" valign="top" background="graphics/panel_back.jpg" class="projectlist">';
	$projectlist .= '</td>';
	$projectlist .= '<td width="125" background="graphics/panel_back.jpg" valign="top" class="projectlist"><span class="style49">';
	
	while ($data = $kernel->DB->fetch_row()) {
		$projectlist .= $data['ProjectName'] . '<br>';
    }
   $projectlist .= '</span></td>';
   $projectlist .= '<td width="65" background="graphics/panel_back.jpg" valign="top" class="projectlist"><span class="style40">';
Thanks

Posted: Sun Apr 15, 2007 8:32 pm
by volka
Highly unlikely. You should add some debug output or even better install a real debugger.

Posted: Sun Apr 15, 2007 9:31 pm
by RobertGonzalez
Comment out the while loop and run it. I'd bet what you say is missing is not missing. I would also bet there is something amiss in the while loop that is making the app do something unexpected. Given the code you have there, there is nothing likely at all to prevent the concatenation of the strings into the variable.

Posted: Sun Apr 15, 2007 10:48 pm
by LiveFree
Everah,

I comment out the first while loop (there are 4), and the only after it runs, but no others after it.

Thanks

Posted: Sun Apr 15, 2007 11:05 pm
by aaronhall
Can you post any relevant code before and after the block you already posted?

Posted: Sun Apr 15, 2007 11:14 pm
by RobertGonzalez
Post all four while loops. With that many, who knows what is happening.

Posted: Mon Apr 16, 2007 12:17 am
by LiveFree
Hey Guys,

Figured it out.

I put this above the loops:

Code: Select all

while ($data[] = $kernel->DB->fetch_row());
And I changed all the while's to foreach's.

Posted: Mon Apr 16, 2007 1:30 am
by JeFFb68CAM
LiveFree wrote:Hey Guys,

Figured it out.

I put this above the loops:

Code: Select all

while ($data[] = $kernel->DB->fetch_row());
And I changed all the while's to foreach's.
:lol:

Posted: Mon Apr 16, 2007 11:18 am
by RobertGonzalez
Glad you got it working.