Jump to content

Trouble with a Link


aztec

Recommended Posts

Hello

 

I am having a problem with putting a link into a table cell, the table is formatted using an external css file. The following is the code for the table row

 

<td colspan="4" class="fieldcellmed"> <input type="text"  id="name" value = "<?php echo $name; ?>"</td>

 

This code will put the name which is contained in $name into the cell. ie value =  value = "<?php echo $name; ?>"</td>

 

What I need in the cell is the result of the following:

 

<a href=<?php echo $name; ?>.php ><?php echo $name; ?></a>

 

Which should be a clickable link.

 

When I enter the code directly after the "value =" it does not create a link but enters part of the code into the cell and part outside the cell.

 

I have searched the board and also the web but most of the web results use Javascript which I do not want to use, any help or advice would be appreciated.

 

Kind Regards

 

Link to comment
https://forums.phpfreaks.com/topic/95086-trouble-with-a-link/
Share on other sites

ok um... I'm having a hard time figuring out what you're asking. But, I'll give it a shot.

 

<a href="<?=$name?>.php<?=$name?>">mylink</a>

 

if $name where "mike" that would yield

 

<a href="mike.phpmike">mylink</a>

 

which doesn't really make a lot of sense

are you trying to pass name as a GET value in the url?

if so that would be

 

<a href="<?=$name?>.php?name=<?=$name?>">mylink</a>

 

which would yield

<a href="mike.php?name=mike">mylink</a>

 

the receiving php script would access the name value through the super global

$_GET['name']

 

and

<?=$name?>

is just shorthand for

<?php echo $name; ?>

 

do that answer your question?

Link to comment
https://forums.phpfreaks.com/topic/95086-trouble-with-a-link/#findComment-487077
Share on other sites

Hello

 

Thanks MikeL for trying to help, I have tried your code and it does not solve the problem I have.  The following code produces a clickable link:

<a href=<?php echo $name; ?>.php ><?php echo $name; ?></a>

 

If $name contains Laura then the result is:

 

<a href=Laura.php >Laura</a>

 

The system is placing [/url] on the end of the link.

 

My problem is to get it into a table cell.

 

Regards

Link to comment
https://forums.phpfreaks.com/topic/95086-trouble-with-a-link/#findComment-487091
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.