How can I include PHP subs in a html <TD> tag using echo

Discussion in 'HTML & Website Design' started by grantp22, Sep 15, 2009.

  1. #1
    How can I include PHP IF-ELSE subs in a html <TD> tag using echo, for example, I need to do the following:

    <?
    if($session->logged_in){
       echo "<h1>Logged In</h1>";
       echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"
           ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] &nbsp;&nbsp;"
           ."[<a href=\"useredit.php\">Edit Account</a>] &nbsp;&nbsp;";
       if($session->isAdmin()){
          echo "[<a href=\"admin/admin.php\">Admin Center</a>] &nbsp;&nbsp;";
       }
       echo "[<a href=\"process.php\">Logout</a>]";
    }
    else{
    ?>
    Code (text):
    And this is what I have, see below, but it doesn't work correctly, the IF-Else get ignored:

    <TD height="82" align="center" style="font-size: 8pt"><? echo "<b>Member Total:</b> ".$database->getNumMembers(); ?>
    <p><? echo "There are ".$database->num_active_users; ?><? echo " registered members and ".$database->num_active_guests; ?><? echo " guests viewing the site."; ?></p>
    <p>
       <? echo "<?"; ?> 
       <? echo "if(".$session->logged_in; ?><? echo "){"; ?>
       <? echo "<h1>Logged In</h1>"; ?>
       <? echo "Welcome <b>".$session->username; ?><? echo "</b>, you are logged in. <br><br>"; ?>
       <? echo "[<a href=\"userinfo.php?user=".$session->username; ?><? echo "\">My Account</a>] &nbsp;&nbsp;"; ?>
       <? echo "[<a href=\"useredit.php\">Edit Account</a>] &nbsp;&nbsp;"; ?>
       <? echo "if(".$session->isAdmin(); ?><? echo "){"; ?>
       <? echo "[<a href=\"admin/admin.php\">Admin Center</a>] &nbsp;&nbsp;"; ?>
       <? echo "}"; ?>
       <? echo "[<a href=\"process.php\">Logout</a>]"; ?>
       <? echo "}"; ?>
       <? echo "else{"; ?>
       <? echo "?>"; ?>
    </p>
    </TD>
    Code (text):
    I basically just need to have this subroutine in my table data cell, any help will be much appreciated, coz this is driving me nuts! :confused:

    Thanks
     
    grantp22, Sep 15, 2009 IP
  2. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #2
    wtf? are you echo'ing php? im confused
     
    crath, Sep 15, 2009 IP