0

The following code is not working, I was getting a white screen with it. Not sure what is wrong. Also, I wasn't sure if it would be better to pass $member_info to javascript and iterate through the html with jQuery?

PHP:

foreach($team_member as $member)
{
  $is_leader= false;
  if(naked_id($member->id) == naked_id($leader->id)){
     $is_leader = true;
  } 

  unset($member_data);
  $member_data->id =   $member->id;
  $member_data->leader = $is_leader;

  $member_info[] = $member_data;
}

HTML:

<?php foreach($member_info as $member) : ?>

    <?php if ( $member->leader == true ) : ?>

        <span id="team-leader">Team Leader</span>

    <?php else : ?>

        <span id="team-leader" style="display:none;">Team Leader</span>

    <?php endif ?>
<?php endforeach ?>
1
  • display errors on ? error reporting set to E_ALL ? Commented Apr 24, 2012 at 6:21

1 Answer 1

2

You need a colon after the foreach (in the HTML snippet you've given). As per the PHP Manual -

In each case, the basic form of the alternate syntax is to change the opening brace to a colon (:)

It would then become :

<?php foreach($member_info as $member) : ?>
Sign up to request clarification or add additional context in comments.

1 Comment

Ahh, thanks for pointing that out. Had it in my code, was a stupid mistake while transcribing the code here, thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.