Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<?php foreach ( $fields as $name => $value ):

        if ( $name == 'Venue' ):
        ?>


        <dt> <?php echo " <a href=''>" $name "</a>" ?> </dt>

        <dd class="tribe-meta-value"> <?php  $value ?> </dd>
        <?php endif ?>

         <?php endforeach ?>



variable $fields is contains two variables $name and $value.
$name is the venue.
$value is the address of that venue i.e. it is a web address. and is entered by the user.
on output screen only the name of the venue will be displayed which will be a hyperlink..which on click must redirect the user to the venue page.
Posted
Comments
Arkadeep De 29-Mar-15 3:19am    
I am not a php expert but still its a try to solve this one. If I am wrong please don't mind.
Is your variable $value contains value like 'http://abc.com.xyz' then I think
" $name " will do the work.
Member 11563816 29-Mar-15 3:33am    
Please change in my code and paste it.. then i will try.
Arkadeep De 29-Mar-15 3:40am    
Bro I had put the whole code of anchor in the comment. but it is taking the code as a real anchor tag. just put $value as href='"$value"'.
Member 11563816 29-Mar-15 3:47am    
i had already tried this.. its not working.
showing forbidden error screen

Two mistakes:
1. you did not concatenate the $name using ".", like this:
<?php echo " <a href=''>".$name."</a>" ?>

2. you did not echo the $value, like this:
<?php echo $value ?>
 
Share this answer
 
v4
Comments
Member 11563816 29-Mar-15 5:45am    
if i will echo $value then it will print the value of $value on the output screen below the value of $name.
Peter Leow 29-Mar-15 7:44am    
Correct. That are the working of dt and dd. You can google for the meaning of them. I will take it that I have solved your problem.
Here in solution 1 there is a small typo error
PHP
?<php echo " <a href=''>
".$name."</a>" ?>


Which is
PHP
<?php echo " <a href=''>".$name."</a>" ?>

Instead of this you can do like this
PHP
<a href="<?php echo $value ?>"><?php $ name?></a>



As you have mentioned $ value is the address it should be the href and $ name is the display value

Hope it helps
 
Share this answer
 
v2
Comments
Peter Leow 29-Mar-15 11:27am    
Thank you, ramyajaya. Corrected the typo.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900