Code after while() loop not executing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Code after while() loop not executing

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Highly unlikely. You should add some debug output or even better install a real debugger.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Post 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
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Can you post any relevant code before and after the block you already posted?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Post all four while loops. With that many, who knows what is happening.
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Post 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.
JeFFb68CAM
Forum Newbie
Posts: 15
Joined: Tue Apr 03, 2007 11:17 pm

Post 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:
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Glad you got it working.
Post Reply