How to php if else statement and return different divs? -


i'm trying create if-else statement, return different divs. believe failing because there many ' in else statement.

<?php $blogentryid = get_the_id();   if ($blogentryid=="1572") { echo '<div>hello</div>' }  else { echo '<div class="socialnews2"><!-- start div social-->                                  <div class="twitternews2">                                 <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php the_title(); ?>" d ata-url="<?php the_permalink() ?>" data-via="giantmangocom">tweet</a>                                 <script type="text/javascript">                                 //async script, twitter button fashiolista.com style                                 (function() {                                 var s = document.createelement('script');                                 var c = document.getelementsbytagname('script')[0];                                 s.type = 'text/javascript';                                 s.async = true;                                 s.src = 'http://platform.twitter.com/widgets.js';                                 c.parentnode.insertbefore(s, c);                                  })();                                 </script>                                 </div>                         </div>                                 <div class="facebooknews2"> <iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->id)); ?>&amp;layout=button_count& amp;show_faces=false&amp;width=80&amp;action=like&amp;colorscheme=light;height=21"" scrolling="no" frameborder="0" style="border:none; overflow:hidden; wid th:80px; height:21px;" allowtransparency="true"></iframe>                                 </div>'  }  ?> 

when want show conditional content, open , close <?php tags instead of using echo statements.

<?php if ($blogentryid == "1572") { ?>  <div>hello</div>  <?php } else { ?>  <div class="socialnews2"><!-- start div social--> ... rest of content here  <? } ?> 

it ensure php code inside of div gets evaluated intended.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -