Quick PHP Help
I'm trying to set up a link that will link to an users profile by their user id and the link will say their username, so heres what i got so far…
<a href=' http://www.example.com/profile.php?lookup= ". $userdata["user_id"] ." '> ". $userdata['user_name'] ."</a>;
And it links to this URL… http://www.example.com/profile.php?lookup=". $userdata["user_id"] ." with this text… ". $userdata['user_id'] ." It doesnt change the $userdata['user_id'] to the user id and doesnt change the $userdata['user_name'] to their username.
Could someone help me out please.
I am not sure what would be causing that. What I can tell you is I put $500 on your running PHP-Fusion :P I would have to see more of your code, chances are its just malformed PHP here is an example
echo "<a href='http://www.example.com/profile.php?lookup={$userdata['user_id']}'>{$userdata['user_name']}</a>";
?>```
and if you are using PHP-Fusion use this instead...
```markup<?PHP
echo "<a href='".BASEDIR."profile.php?lookup={$userdata['user_id']}'>{$userdata['user_name']}</a>";
?>```
instead of <a href=' http://www.example.com/profile.php?lookup= ". $userdata["user_id"] ." '> ". $userdata['user_name'] ."</a>;
try this..
<a href='http://example.com/profile.php?lookup='" . $userdata['user_name'] . "'>" . $userdata['user_name'] . "</a>;
notice that you must put ' before the " after lookup= and " before ' to end the href value. that should work.
Are you kidding chislam, that will give a broken tag. after PHP outputs that it would look like <a href='profile.php?lookup='id'>name</a>
The way he explains it, it sounds like he doesnt know PHP and he doesnt have it in PHP tags, if it was in PHP tags he would be getting blank or errors. he isnt getting eaither. I can almost gurentee you he doesnt have it in php tags and is echoing it out properly just look at my example above