lundi 4 septembre 2017

How to write an echo inside an echoed html link

Ok so im trying to create a navigation link that can take a user to there profile page. I made a function "find_user_by_id($user_id)" to use for...well...locating the user via there id. All I need is to figure out how to have it where if the user is currently ON there profile page, it shows a "logout" link where the "profile" link would normally be placed. The only problem is, I don't know how to Echo urlencode($user["id"])inside an already echoed <a href>tag. The code below might help you understand a bit more:

if ($accessPage =='profile') {
        echo "<a href=\"logout.php\">Logout</a>";
    } else {
        echo "<a href=\"profile.php?id=<?php echo urlencode($user["id"]); ?>\">Profile</a>";
    }

Aucun commentaire:

Enregistrer un commentaire