Basic variables coding mistake - Please help me

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

philfutureproof
New php-forum User
New php-forum User
Posts: 1
Joined: Sun Mar 23, 2014 1:52 pm

Basic variables coding mistake - Please help me

Postby philfutureproof » Sun Mar 23, 2014 2:33 pm

I am relatively new to php coding and have an error that Dreamweaver says is a syntax error on a line of code that features a variable i have used.

The context is coding for a wordpress plugin called "Advanced Custom Fields or ACF" in which I use a "repeater field"(documentation - http://www.advancedcustomfields.com/resources/field-types/repeater/)

What I'm trying to do is generate a list of people with their Position, Name and email details each placed in a table div so that if there is no value in a particular field on one of the lines, it will still generate an empty table div and hence not mess up the layout. This is why there is an if statement for each variable using else{echo'<td>' . '</td>' etc

The code is based on the "Advanced Loop" example on the ACF documentation page (see url above) and is as follows. . .

Code: Select all

<?php if( have_rows('admin_council') ): ?>
 
   <ul class="slides">

<?php while( have_rows('admin_council') ): the_row();
 
      // vars
      $council_title = get_sub_field('council_title');
      $council_name = get_sub_field('council_name');
      $council_name_link = get_sub_field('council_name_link');
      $council_email = get_sub_field('council_email');
 
      ?>
 
      <li class="slide"><table><tr>
       
         <?php if( $council_title ) { ?>
                echo '<td>' . $council_title . '</td>';}
            else {
               echo'<td>' . '</td>'
                    <?php } ?>
         

         <?php if( $council_name ) { ?>
                echo'<td>' . $council_name . '</td>' ;}
            else {
               echo'<td>' . '</td>'
                    <?php } ?>

         <?php if( $council_email) { ?>
                echo'<td>' . $council_email . '</td>' ;}
            else {
               echo'<td>' . '</td>'
                    <?php } ?>
               </tr>
            </table>
      </li>
   <?php endwhile; ?>
   </ul>
<?php endif; ?>


At the bottom of this post is code for the complete wordpress page template from which the code above comes from - For clarity . . the full page without this code does parse correctly.

Many thanks and I would most appreciate any help in understanding why my coding is not working (
This is the first time I have posted anything in this forum).

Phil


Code: Select all

<?php
/*
Template Name: Page-Admininstration
*/
?>

<?php get_header() ?>

<div id='content_container'>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>


<h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">

<?php if (is_page ('Funding') ) { echo "How Newcomen is Funded";
}
elseif (is_page ('Our Logo') ) { echo "The Newcomen Logo and its Origins";
}
elseif (is_page ('Membership') ) { echo "Newcomen Membership";
}
elseif (is_page ('Publications') ) { echo "Our Publications";
}
elseif (is_page ('The International Journal') ) { echo "The International Journal for the History of Engineering and Technology";
}
elseif (is_page ('Past Papers') ) { echo "The Newcomen Archive";
}
elseif (is_page ('Subject Areas') ) { echo "Subjects";
}
elseif (is_page ('622') ) { echo "Help Pages";
}
else
{ echo wp_title ('');
} ?>

</a></h1>

<?php if (is_page ('The International Journal') ) {?> <div class="subtitle">(Formerly Transactions of the Newcomen Society)</div>
<?php } ?>

<div id='main'>

<?php the_post_thumbnail( 'category-page' ); ?>

<?php the_content('Read More....'); ?>



<?php if( have_rows('admin_council') ): ?>
 
   <ul class="slides">
 
   <?php while( have_rows('admin_council') ): the_row();
 
      // vars
      $council_title = get_sub_field('council_title');
      $council_name = get_sub_field('council_name');
      $council_name_link = get_sub_field('council_name_link');
      $council_email = get_sub_field('council_email');
 
      ?>
 
      <li class="slide"><table><tr>
       
         <?php if( $council_title ) { ?>
                echo '<td>' . $council_title . '</td>';}
            else {
               echo'<td>' . '</td>'
                    <?php } ?>
         

         <?php if( $council_name ) { ?>
                echo'<td>' . $council_name . '</td>' ;}
            else {
               echo'<td>' . '</td>'
                    <?php } ?>

         <?php if( $council_email) { ?>
                echo'<td>' . $council_email . '</td>' ;}
            else {
               echo'<td>' . '</td>'
                    <?php } ?>
               </tr>
            </table>
      </li>
 
   <?php endwhile; ?>
 
   </ul>
 
<?php endif; ?>


<!--ATTACHMENT CODES GO HERE-->

<?php $attachments = new Attachments( 'attachments' ); ?>
<?php if( $attachments->exist() ) : ?>
<div id="attachments">
  <h4>Downloads</h4>
  <ol>
    <?php while( $attachments->get() ) : ?>
      <li>
   <a class="pdf" href="<?php echo $attachments->url(); ?>" target="_blank"><?php echo $attachments->field( 'title' ); ?></a>
<div class="attachmentCaption">
<p><?php echo $attachments->field( 'caption' ); ?></p>
</div>
      </li>
    <?php endwhile; ?>
  </ol>
</div>
<?php endif; ?>



</div>

<?php endwhile ?>
<?php endif; ?>

<?php get_sidebar() ?>
<?php get_footer() ?>

Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest