Jump to content

Why can't I use <a> into a php variable?


DNA180

Recommended Posts

Hello guys... I have a problem here. I am trying to put a link into a php variable and it isn't show up. Here is what I am trying to do:

$text .= "<span><a href='index.php?option=com_alphauserpoints&view=account&userid=".$data."&Itemid=24'><div id='UserProfile_Normal' onMouseOver= id='UserProfile_MOver' onMouseOut= id='UserProfile_MOut' title='None' alt='profile'> </div></a></span>";

Does anybody find something wrong on syntax or something??? Thank you in Advance!!!

Link to comment
Share on other sites

The PHP isn't the problem. It's the HTML. First of all, you can't have <div> elements inside <a> elements. If you want a block link, then use CSS to make it a block. The second thing: Your onMouseOver and onMouseOut attributes look empty to the browser because their values aren't within quotation marks. The other thing is that if you want to change properties of the specific element you need to use this. onmouseover="this.id='UserProfile_MOver'"

Link to comment
Share on other sites

I don't know if I can't have <div> element inside <a> in this case, but in other case I have done this and worked!!!Here is an example:

<table height='100%' width='auto' border='0' cellspacing='0' cellpadding='0'> \n\<tr> \n\<td> <a href='index.php?option=com_content&view=frontpage&Itemid=2'> \n\<div id='HomeNormal' onMouseOver= id='HomeMOver' onMouseOut= id='HomeMOut' title='none' alt='home'> </div></a> </td> \n\</tr> \n\</table> \n\

Anyway... I'll do as you said it looks more logical. But what should I do with the <a>??? Even if I add it like this:

<a href="...">Something</a>

without <div> etc, it isn't show up again!!! Thank you for your answer!!!

Link to comment
Share on other sites

You should check the source code of the page to see if it's being printed. If appears in the source code then the problem is CSS, if not then the problem is PHP. You might be overwriting the variable before printing, or printing a different variable. You haven't shown enough PHP to determine what the problem is.

Link to comment
Share on other sites

if you've made changes, the post the changes. that's all he was asking for. we don't assume what people write, since usually, since they are here, something is wrong the code itself is incorrect.

Link to comment
Share on other sites

The code in your first post

$text .= "<span><a href='index.php?option=com_alphauserpoints&view=account&userid=".$data."&Itemid=24'><div id='UserProfile_Normal' onMouseOver= id='UserProfile_MOver' onMouseOut= id='UserProfile_MOut' title='None' alt='profile'> </div></a></span>";echo $text;

is a PHP code that generates the HTML code

<span><a href='index.php?option=com_alphauserpoints&view=account&userid=someData&Itemid=24'><div id='UserProfile_Normal' onMouseOver= id='UserProfile_MOver' onMouseOut= id='UserProfile_MOut' title='None' alt='profile'> </div></a></span>

(assuming $data = "someData")You then say you have generated the HTML code

<a href="...">Something</a>

But what PHP code did you generated that HTML code with? That's the question. And also if you've checked the full generated code and verified this is truly part of it (rather than it being part of the PHP code).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...