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
Related
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>
I am currently working on home.php where I have the following anchor link echo'd:
<a href='#?id=$thought_id' class='toggle-comment' data-id='$thought_id' style='padding-left: 5px;'> Comments ($num_of_comments) </a>
Now, when I hover over the Comments anchor, I get the id of the thought fine. It's just that when I hover over the link, or when I click the link, the url reads:
http://localhost/home.php#?id=210
So, 210 is the ID of the thought the comments anchor is assigned to, which works. But I do not understand why the file name is appending to the anchor link when it hasn't been defined to do so.
Even when I put <a href='#'> The URL still reads http://localhost/home.php#
Your browser is going to show you the full, canonical URL (including the anchor) when you hover over a link. It's the same link that will be copied to your clipboard if you right-click it and choose "Copy Link Location".
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>
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="">
I'm having difficulty creating a button on my catalog page, the catalog page returns either 8 15 or 20 products from a mysql database so i use a loop to pull each product out of the database, and i need a addtocart button which uses javascript to create an onmouseover effect the code is as follows
echo "<a href=\"catalog.php?buyproduct=$productNumber\" onmouseover=\"document.crt.src='images/addcrt_btn_dn.png'\"
onmouseout=\"document.crt.src='images/addcrt_btn.png'\">
<img src=\"images/addcrt_btn.png\" name=\"crt\" alt=\"Add to cart\" width=\"81\" height=\"24\"> </a>";
it displays the image properly but nothing happens when the mouse is put over the image. I'm guessing that this could be caused because since either 8 15 or 20 of these images are being created, the "name=crt" is throwing the whole thing off, if so how could i fix this?
Any advice would be helpful thank you!
Instead of using the name attribute on the <img>, I would start by recommending you use the id attribute, as follows:
<img id="crt" />
Then you can change the src as follows:
document.getElementById('crt').src = 'images/addcrt_btn_dn.png';
Make sure you properly escape all those quotes properly, or work on generating the content another way (here's an example sticking with the name attribute):
...
?>
<a href="catalog.php?buyproduct=<?php=$productNumber?>" onmouseover="document[crt].src='images/addcrt_btn_dn.png'" onmouseout="document[crt].src='images/addcrt_btn.png'">
<img src="images/addcrt_btn.png" name="crt" alt="Add to cart" width="81" height="24">
</a>
<?php
...