Jump to content

Recommended Posts

Hi Guys,

Could someone take a look at my code for me?! I've made another stupid error somewhere.

 

while (odbc_fetch_row($result_Area)) 
	{
	$Area_01=odbc_result($result_Area,"Area_01");	
	$Area_02=odbc_result($result_Area,"Area_02");	
	$Area_03=odbc_result($result_Area,"Area_03");	
	$Area_04=odbc_result($result_Area,"Area_04");	
	$Area_05=odbc_result($result_Area,"Area_05");	
	}

$id = $Area_01;

while(!empty($id)){

     echo "moose<br>";
     //some sample code to check the loop works!

     if ($id == $Area_01){$id == $Area_02}
     elseif ($id == $Area_02){$id == $Area_03}
     elseif ($id == $Area_03){$id == $Area_04}
     elseif ($id == $Area_04){$id == $Area_05}
     else {$id == $Area_05}

}

 

So for example if fields Area_01, Area_02, Area_03 are populated and Area_04 is empty, I would expect to see:

 

moose

moose

moose

 

Instead I get the following error message.

 

Error:

Parse error: parse error, unexpected '}' in D:\Intranet v3\Sales\home.php

 

Can anyone see where I'm going wrong?

Link to comment
https://forums.phpfreaks.com/topic/67019-solved-error-in-code-while-loop/
Share on other sites

Cheers MadTechie,

I obviously need to catch up on some sleep!

 

Here's my revised and working While Loop in case anyone else was looking!

 

while(!empty($id)){

echo "- $id<br>";

if ($id == $Area_01){$id = $Area_02;}
elseif ($id == $Area_02){$id = $Area_03;}
elseif ($id == $Area_03){$id = $Area_04;}
elseif ($id == $Area_04){$id = $Area_05;}
elseif ($id == $Area_05){$id = 'NULL';}
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.