DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   php within echo statement / hide element (http://www.daniweb.com/forums/thread201354.html)

cjay175 Jul 2nd, 2009 8:35 pm
php within echo statement / hide element
 
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:
<div class='dateauthor'>
            <small class='capsule'><?php the_time('F jS, Y') ?> by <?php the_author() ?>
        </small>
        </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
<?php if ($author=="admin"){echo "hello24241";} ?>
and edit here...
<?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

cjay175 Jul 2nd, 2009 8:38 pm
Re: php within echo statement / hide element
 
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 :$

Wickedself Jul 3rd, 2009 2:43 am
Re: php within echo statement / hide element
 
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


All times are GMT -4. The time now is 6:32 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC