Please can I get some help with this - I have this part of code:
echo '<li><span>'.mg_wpml_string($type, $copt).':</span> '.$val.'</li>';
How to make this part
.$val.
clickable, so In fact how to put this part in a href so that users can click on this?
This is ordinary text ling but all values are entered as http addresses but I can not click on them.
Thank you
Just put the HTML-code for a link (a href) in there...
echo '<li><span>'.mg_wpml_string($type, $copt).':</span> '.$val.'</li>';
Perhaps?
[...snip...]:</span>' . $val . '</li>';
Related
In a helper plugin for WooCommerce for WordPress, I'm trying to create a custom message to be sent to a buyer.
I don't know why in all the emails that are sent out, %0d%0a is getting added behind the URL in the href attribute. I have tried several different combinations and nothing is working.
This is what I'm trying to do:
echo "<a href='$cl'> Please click here to redeem the coupon</a>";
But because %0d%0a is being added at the back of it the URL doesn't work properly for coupon codes.
This is what the URL looks like afterwards:
https://www.example.com/product-1/?couponCode=TDXGUA9G&utm_source=test&utm_medium=testt&utm_campaign=test&aff_code=TSJU89XYZ%0d%0a
The only thing that doesn't add %0d%0a is this:
echo $cl;
But I want to be able to use the <a> tag so that the buyer doesn't have to click on a long URL link.
Try this
echo "<a href='" . $cl . "'> Please click here to redeem the coupon</a>";
If you still have the issue, check how $cl was created.
I really appreciate all the responses. But I just want to post the code that finally worked for me after 7 hours of work. I understand that it looks silly but this is the best I could do for now. Here's what worked for me:
?>
Click here to take <?php echo ' '.$_product_name.'</span>';
I just encountered the same issue, but I'm using ASP.NET. All I did was delete the single quote and type it again. Now it works.
<asp:HyperLink ... NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Name") %>' />
There were possibly some extra invisible characters which needed to be deleted.
I have been toying around with the idea where I echo a link and it changes based on the string I got from my database. (the GET command)
Here is the code I been working with:
<?php echo '<a href="submittoplay.php?username="' . ($username) . ">";?>
I want the output of the echo to appear like so, where $username = bob
<a href="submittoplay.php?username=bob or in the address bar when I click on the link to be submittoplay.php?username=bob
But when I run the code only"<a href="submittoplay.php?=username" shows. It doesnt seem to want to take my string that I had gathered from the database and plug it into the echoed link.
I know $username is a valid string, I tested it and do get the result I am looking for.
Any help would be appreciated!
Thank you!
here it goes :--
$username='bob';
echo 'User link';
inside php
$user_name='sample';
echo 'Your link';
Fiddle Link
Outside Php
Your link
Fiddle Link
I have a site what user can submit content.So i want to avoid spam link by add on a tag rel="nofollow".How can i do that with jquery or php
This is link
Use this
$("a[href='http://mnking.net']").attr("rel", "nofollow");
You can do:
$(document).ready(function(){
$("a").attr("rel", "nofollow");
});
Put post into a separate div, let's say class="post"
and then just simple jquery code:
$('.post a').attr('rel', 'nofollow');
if you get the link using $_POST, you could use the following code (written in PHP):
$url = $_POST['url'];
$tag = 'This is link';
In PHP , the sign . (a simple dot) is used to concat strings.
Good luck.
In a php project I need to add items to database, list them & allow the user to edit & update items using a single page.
This is my code to edit item link in HTML table
echo ' Edit ';
When a user click on the above link I need to hide Add button and display two new buttons to Update & Cancel the edit + display selected item name in a Text box to Edit.
To hide and display buttons I'm using jQuery and to display the item name i need to use PHP.
Here when i put PHP code and reload the page with $_SERVER['PHP_SELF'] (as in above code), hiding & displying of buttons is lost after the page load. (If I remove the _SERVER['PHP_SELF'] code from link it hides and display buttons as expected (but no php code run))
How can I retain the page update by Javascript and run the PHP code?
I'm new to PHP am I missing something in my code?
$_SERVER['PHP_SELF'] is only a refrence to the php document itself, it doesnt contain any key/value pairs. try using:
echo '<a href=" '.$_SERVER['PHP_SELF'].'?'. $_SERVER['QUERY_STRING'].
'&name=edit&id=' .$rowCountry->CountryId .
' " id="edit" onClick="MyFunction()"> Edit </a>';
edit:
i may have misunderstood the question. you may need something like this:
<?php
if(!empty($_GET[edit])){
//echo code that u want to show AFTER they click the edit link
}else{
//echo the code to show if they have NOT clicked the edit link
}
?>
Ok, i have some data that is being populated via a php query to a database. I am getting comments that a user enters. I am displaying the returned data in a variable as shown below. If a comment does not exist then it would display an "add comment" link. The comment is just displayed as text at first. If a comment exists then it would display the comment along with an "edit" comment" link.
This is the functionality i am looking to have: 1) when you click on "add comment" an input field would be displayed to the left of the "add comment" link and that link would then turn in to two links that read "save" and "cancel". I know how to do the save link but i would like to know how to make the "cancel" link revert the area back to just having the "add comment" link. 2) when you click on "edit comment" then i would like the same functionality with an input field and the "save" and "cancel" links; however, i would like the input field to be pre-populated with the comments text that is being pulled via the comments variable. I'm thinking maybe this can be done with some css display toggling none and block/inline. Not sure exactly though. Any help is greatly appreciated!
PHP Code:
if(!$comments){
echo "<span style='font-size:12px;'>[<a href='#'>Add a Comment</a>]</span>";
}else{
echo "<span style='font-size:12px;'>NOTES: " . $comments . " [<a href='#'>Edit Comment</a>]</span>";
}
One final question: how should i handle if the comments have special characters or quotes? Actually i guess i'll need to worry about those before teh variable is created, correct? How do i do that? Thanks so much!
UPDATE: I appreciate the help on handling special characters, but i really need the first two questions answered more. Thanks for any more help anyone can provide me!
answer to 1st and 2nd question :
you can play with javascript or jquery....for eg
make 2 divs
<div id="addcommentBox" style='font-size:12px;'>[<a onclick="$('#addcommentBox').hide();$('#savecommentbox').show();">Add a Comment</a>]</div>
<div id="savecommentbox"><input type="text"/>Save<a onclick="$('#addcommentBox').show();$('#savecommentbox').hide();">Cancel</a></div>
give css property to #savecommentbox as display:none;
although there are many ways this is the simple one...for edit also you can follow the same code.just give the input value as $comments
You have to pass the variable from htmlspecialchars() before echoing them.
echo "<span style='font-size:12px;'>
NOTES: " . htmlspecialchars($comments) . "
[<a href='#'>Edit Comment</a>]
</span>";
<textarea name="comment"><?php echo htmlspecialchars($comments);?></textarea>
you can use htmlentities
one answer as many have given is htmlspecialchars().
when you click on the add comment link . show the text area. when you click on the cancel, do a hide of the text area and show the add comment link again. i feel if u use jquery u can use show / hide functions.