user9373919
user9373919

Reputation: 27

PHP a href echo with span not functioning properly

I have the code

echo '<span class="imperial-username">';
echo'<a target="_blank" href="profile/'.$row['name'].'">'.$row['name'];'</a>';
echo'</span>';

which functions fine when i press the name it takes me to the profile. But if I click the image also above the name it will go to the person who is above on the list, as I have a list of links. And only goes to there profile if you click the name specifically.

Also all other links on the page seem to be not functioning properly and going to random profiles when pressed, the links are carrying over down the page or something is what I assume, maybe code not closed properly, but I see nothing that should be causing this.

Upvotes: 1

Views: 184

Answers (3)

Manjeet Kumar Nai
Manjeet Kumar Nai

Reputation: 1570

echo '<span class="imperial-username">'; 
echo '<a target="_blank" href="profile/'.$row['name'].'">'.$row['name'].'</a>';
echo '</span>';

Upvotes: 1

Suhag Lapani
Suhag Lapani

Reputation: 695

please try this

echo '<span class="imperial-username">';
echo'<a target="_blank" href="profile/'.$row["name"]>'.$row["name"].'</a>';
echo'</span>';

Upvotes: 1

Syscall
Syscall

Reputation: 19780

You have a semicolon ; instead of a dot . in .$row['name'];'</a>';.

It is not a syntax error, because the instruction '</a>'; is valid but has just no effect.

Upvotes: 1

Related Questions