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>
Related
I'm trying to get a field in the customizer for inserting the link to the LinkedIn profiles of my customer.
Before I made a text field and used the wpautop function. That works very well. Does anybody know a quick way to let the user insert a plain link like example.com what will be displayed like https://example.com?
With a page _blank please :-)
For my text i used this code:
<?php echo wpautop (get_theme_mod('themename-expression-text') )?>
I guess i'll need something like:
<?php echo wpautoahref (get_theme_mod('themename-expression-text'))?>
I just can't find it :-)
Fixed it! Definitely to deep into the code today :-)
<a target="_blank" href="<?php echo (get_theme_mod('themename-example-externallink') )?>">Linkedin</a>
The page I refer to, with the anchor tag, should display what I write within it.
For eg:
echo "<a href='".$question."'>$question</a>"
should display the text in $question , as a text in the page that it links to.
How can i achieve this using php or html?
PS: I'm new to both php and stackoverflow! So any suggestions are welcome.
Pass data to URL as GET parameter:
In PHP:
if (isset($_GET['q'])) {
echo htmlspecialchars($_GET['q'], ENT_QUOTES);
}
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>
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
$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