linked text instead of web address - php

I've got some php code that is calling in a website link from my database. The result is the full website link 'www.store.com', but what I'd prefer is to just have some linked text e.g., 'read more' so that the actual web address is not visible. The portion of the code that is specific to the website call is as follows:
<?php $v['website'] = str_replace('&','&', $v['website']); ?>
<website><?php echo $v['website']; ?></website>

In the case $['website'] contains the web address...
Then you are looking for soemthing like this
<a href="<?php echo $['website']; ?>" >Read more </a>
I would also recommend add target="_blank" to the <a> tag, so the user wont leave your website and the link will open in a new tab.

I don't know what the <website> tag is. But for the anchor tag this,
Read More
will work.
Also see,
Adding php code to html anchor tag

<?php $v['website'] = str_replace('&','&', $v['website']); ?>
<website><?php echo 'Read More'; ?></website>

Related

How to create an Href using a MySQL column VARCHAR/TEXT

I am currently trying to link a "courseName" variable from mySQL table into an a href ="" code because I don't want each clickable link to go to the same sight.
'.$record['courseName'].'
This is my current line of html code. I need to replace the # with .$record['courseURL'] but I can't find a way to do it. Is there anyone who can help or push me in the right direction?
If I understand you correctly, you are trying to do this.
For example, let your $record['courseName'] variable be 'course.php'.
$record['courseName'] = 'main.php';
Your "a" tag should look something like this.
echo '<a href ='. $record['courseName'].'>'.$record['courseName'].'</a>';
You can just print the course url into href attribute. Try:
<a href="<?php echo $record['courseURL']; ?>">
<?php echo $record['courseName']; ?>
</a>

PHP Snipped not rendering in iframe

I'm trying to open the user_url within an iframe on a private user page in Wordpress.
I put the following code into a snippet:
<?php echo get_the_author_meta('user_url',$userID); ?>
When I use the short code on the user page it does display the user URL, I can also use it in an hyperlink like this:
link text
But when I put the short code into an Iframe the short code does not change into the URL anymore.
<iframe src="[cmruncode name='dash']" height="300" width="300" title="Iframe"></iframe>
Does anyone knows why this is not working and know a solution?
Thanks Peter
If you are using WordPress shortcode then you have to call shotcode using function do_shortcode.
You can try this one
<iframe src="<?php echo do_shortcode( '[cmruncode name="dash"]' ); ?>" height="300" width="300" title="Iframe"></iframe>
And I'm not sure why anchort text display right output. That's weird.
Anyway if you used do_shortcode to output your shortcode then it will work every place.
This only works when I put it directly into the template, in that case no snippet-shortcode is needed at all. But the content needs to be hidden when the user is logged-out.
Normally the plugin "client portal" that I use should take care of this
but it has a content block that does not support PHP and also does not render the php snippet that I made.
Any suggestions?
The solution was to put the iframe code completely into a snippet.
Like this:
<iframe src="<?php echo the_author_meta('user_url',$userID); ?>" height="2400" width="100%" title="Iframe"></iframe>

Problems with anchor tag - PHP

I wrote some code for a real estate website and I have a little problem.
When I click on an ad, I want to make the page go back at the line. In order to do that I use the anchor but it doesn't work.
In the main page I've put this
In the page of the ad detail I've put this:
<a href="affitti.php?location=<?php echo $do_query[location];?>&&lang=<?php echo $lang;?>#<?php echo $do_query[id];?>" >
It has to return at the number id of the anchor, but it doesn't go back either.
Can anyone help me?
It seems that you don't have the anchor per se. Check that is not missing:
<a name="anchor"></a>
Click here to go anchor
either use the name attribute as Marcos explains in his answer or an id
see below
<a id="<?php echo $do_query[id];?>"></a>
and
<a href="affitti.php?location=<?php echo $do_query[location];?>&lang=<?php echo $lang;?>#<?php echo $do_query[id];?>" >
the first placeholder needs to have an id set and the actual link will reference the placeholder by #id

Assign button image to links from db

php newbie. echoing out links to product pages, the following code works fine:
<a href="<?php echo $rows[$product_buy];?>"<p>Click Here for Details</p></a>
but, would like to change text link "Click Here..." to an image of a button.
tried different ways, searched around, still haven't figured it out
You could simply style your link to look like a button (by giving it a class/id to make sure not all links are targeted) or you can put an img tag between the a tag.
<img src="path_to_img" alt="">

How to open a new window with target='_blank' ? My code doesn't work

$html=<<<html
<tr><td>$i.$title</td><td>$count</td><td class="nowrap">$locationtext</td></tr>
html;
echo $html;
How to open a new window in the code above? target='_blank' doesn't work.
Your target attribute is stuck inside your href attribute. Try this:
$html=<<<html
<tr><td>$i.$title</td><td>$count</td><td class="nowrap">$locationtext</td></tr>
html;
echo $html;
look at the code output by that code. It will look like this:
<tr><td>$i.$title</td><td>$count</td><td class="nowrap">$locationtext</td></tr>
and you want it to be
<tr><td>$i.$title</td><td>$count</td><td class="nowrap">$locationtext</td></tr>
That is:
link
The reason it's not working is because you haven't separated your link attributes properly. Try outputting the href and the target with proper separation (ie, close your quotes).
Use this:
<a href="offtask.php?taskid=$taskid" target='_blank'>
instead of
<a href="offtask.php?taskid=$taskid target='_blank' ">
<a href="offtask.php?taskid=$taskid" target="_blank">
I have tried putting the target="_blank" in a number of places, this code comes from a rss reader but I don't want people to click and leave my site but to just open another tab
if($linked ) $msg = ''.$msg.''; // Puts a link to the posts
Use The target="_blank" in front of the href in php

Categories