php within echo statement / hide element

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: May 2009
Posts: 20
Reputation: cjay175 is an unknown quantity at this point 
Solved Threads: 0
cjay175 cjay175 is offline Offline
Newbie Poster

php within echo statement / hide element

 
0
  #1
Jul 2nd, 2009
hi all,

I am wondering if someone could give me a quick hand with some php im trying to edit in Wordpress.

Heres the original peice I am trying to edit:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <div class='dateauthor'>
  2. <small class='capsule'><?php the_time('F jS, Y') ?> by <?php the_author() ?>
  3. </small>
  4. </div>

What I want to do is when "the_author" equals "admin" for the div to be hidden or deleted.

I have added this to make sure that it can find admin
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <?php if ($author=="admin"){echo "hello24241";} ?>
and edit here...
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <?php $author=the_author() ?>


My question I guess would be is there a statement that would be able to hide/delete the div? Or should I be re-writing this code, like this...

<?php $author = the_author(); ?>
<?PHP if ($author=="admin")?> working
<?php else: ?> \* I get an error on this line *\
        <div class='dateauthor'>
            <small class='capsule'><?php the_time('F jS, Y') ?> by <?php the_author() ?> 
			</small>
        </div>
<?php endif; ?>


Thanks for any help,

and if you need me to be a little more clear just ask,

tian
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 20
Reputation: cjay175 is an unknown quantity at this point 
Solved Threads: 0
cjay175 cjay175 is offline Offline
Newbie Poster

Re: php within echo statement / hide element

 
0
  #2
Jul 2nd, 2009
I apologize as soon as I sent this I remembered I started the thread in wrong are, not sure how to move this but if a mod could delete this ill make new post in php.

Thanks
Last edited by cjay175; Jul 2nd, 2009 at 8:43 pm. Reason: wrong thread
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 8
Reputation: Wickedself is an unknown quantity at this point 
Solved Threads: 0
Wickedself Wickedself is offline Offline
Newbie Poster

Re: php within echo statement / hide element

 
0
  #3
Jul 3rd, 2009
You are getting an error in the else line because

you are trying to use VB type if else in PHP.

But PHP is originally based on C language so that

if else will surely return an error

to learn more about the if else statement in PHP

Follow this link: http://www.w3schools.com/php/php_if_else.asp
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC