echo "<td>$row[instagram]</td>";
I am trying to add target="_blank" to that somewhere just so when I click the link it opens in a new tab, for the life of me I can't get it.. I've tried it everywhere and every way it would exhaust me to retype all of them but this is my current line.
Try this:
<a target=\"_blank\" href=\"https://www.instagram.com/" . $row['instagram'] . "\">$row[instagram]</a>
It will add the target attribute to _blank
try to use target='_blank'
echo "<td><a target='_blank' href=\"https://www.instagram.com/" . $row['instagram'] . "\">$row[instagram]</a></td>";
Related
I am working on my college web design course during my easter break and have run into a problem...
I have a menu on each page that I have removed from the html pages and written into a php file and that is used with an include in each page. Everything works fine apart from the onclick events that when clicked SHOULD load another page but at the moment does not do anything.
Here is my php file...
<?php
echo "<div id='leftPnl'>";
echo "<div class='navcon'>";
echo "<button class='static'
onclick='window.location.href='"."./index.html'".">Home</button>";
echo "<button class='accordion'>Gallery</button>";
echo "<div class='panel'>";
echo "<button class='static' onclick='window.location.href='"."./html/countryside.php'".">Countryside</button>";
echo "<div id='socialmedia'>";
echo "<img src='../images/sitewide/map.png'>";
echo "<br>Contact us on...<br>";
echo "<a class='fab fa-facebook-square fa-2x'
onclick='msg('"."Facebook"."')"."></a>";
echo "<a class='fab fa-instagram fa-2x' onclick='msg('"."Instagram"."')".">
</a>";
echo "<a class='fab fa-twitter-square fa-2x'
onclick='msg('"."Twitter"."')"."></a>";
echo "<a class='fab fa-tumblr-square fa-2x' onclick='msg('"."Tumblr"."')".">
</a>";
echo "<div id='clock'>";
echo "<p class='date'>{{ date }}</p>";
echo "<p class='time'>{{ time }}</p>";
echo "</div>";
echo "</div>";
echo "</div>";
?>
on running the file and inspecting the element in Chrome, the url that the href uses is not formatted correctly the ./ are missing and a single quote is also missing.
Is it simply that I am getting confused with the position of my single and double quotes in the php?
Thanks.
PS, I apologise if this has already been asked - I looked and could not find the answer.
Is it simply that I am getting confused with the position of my single and double quotes in the php?
Yes.
Look at the output of the PHP. To take one example:
onclick='msg('Facebook')>
You start the attribute value with '.
Then you try to use ' inside it.
Then you forget the ' at the end!
There is no reason to nest any of this code inside PHP string literals. All that achieves it making it harder to debug.
Just write the HTML directly, outside of <?php ... ?> sections.
It wouldn't be a bad idea to get rid of the intrinsic event attributes too, and use JavaScript to bind event handlers.
I want to make that row a link, but I dont know how to add an a href attribute... That row shows information from a DB and I just want to make ir clickeable and not only as plain text. Thank you
This is the row I wanna turn into a link...
echo '<td>' . $row['nombre'] . '</td>';
Wrap the text in an anchor (a) tag.
echo '<td>' . $row['nombre'] . '</td>';
You should also probably take a look at the W3schools HTML5 tutorial.
Just add the <a> to your HTML, and include the URL in it.
echo "<td><a href='script.php?id={$row['nombre']}'>{$row['nombre']}</a></td>";
echo "<td>
<a href='yourfile.php?subDom=$row['nombre']'</a>
</td>";
Then you can check for if link is clicked, you can trigger action for click. Like below:
if($_GET['whateverComingFromDB'] == "whatDoYouWantToCompare"){
//...Anything you want to happen after click the link
}
I am trying to open a bootstrap modal window containing product image and information. My problem appears to be the #uoc-modal inside the data-target. Can some please tell me how to correctly enter the data-taget id inside an echo?
echo '<a "data-toggle='modal'", "data-target='#uoc-modal'" href="' . get_the_permalink() . '">';
From your question code, you should escape it
echo '<a "data-toggle=\'modal\'", "data-target=\'#uoc-modal\'" href="\' . get_the_permalink() . \'">';
But, I think this should work
echo '<a data-toggle="modal" data-target="#uoc-modal" href="'.get_the_permalink().'">Modal</a>';
But anyways, you don't need data-target attribute for <a> element. Just use href instead.
Try this code:
echo '<a "data-toggle=\'modal\'", "data-target=\'#uoc-modal\'" href="\' . get_the_permalink() . \'">';
Good evening
I want my hyperlinks destination to be filled by a value from my database. However, when I click the link in my app it doesn't clear the "http://localhost/videoStorageApp/" before inserting the URl value from the database.
QUESTION: How do I clear the web browser url so only the URL value form the database is used?
WHAT I AM GETTING: http://localhost/videoStorageApp/'www.sonsofanarchy.tv'
WHAT I WANT: www.sonsofanarchy.tv
CODE:
This is the line that displays the hyperlink in question, if more code is needed please ask and ill add anything else that's needed:
echo '<td> ' . $row['url'] . '</td>';
echo '<td> ' . $row['url'] . '</td>';
You are probably missing "http://" in your href attribute.
<a href="google.com">
... will take you to http://currentsite.com/maybe-a-subfolder/google.com
<a href="http://google.com">
... will take you to http://google.com
I am setting up a wordpress website and want to alter a plugin to work with another so that when a news link is clicked it will open in a lightbox using an iframe. I believe the following instances to be where the link is made.
<a href="<?php echo $link; ?>
I am looking to add the following to the link, at the end.
?iframe=true&width=100%&height=100%" rel="prettyPhoto[iframes]"
I am unsure of how to combine the two. I am hoping by doing so that I correctly located and understood what needed to be changed. If you want to see the full PHP file I have added it to http://pastebin.com/sFqSb1Ha
While I wouldn't mind someone telling me the answer, I would be happy to just be pointed in the right direction for the knowledge I need to study to accomplish this.
Try this:
<a href="<?php echo $link . '?iframe=true&width=100%&height=100%"' . 'rel="prettyPhoto[iframes]"'; ?>
I can see that there are a lot of $link echos in the code you provided. To apply that attrubute for all, you may set $link before, like:
$link = $link . '?iframe=true&width=100%&height=100%" rel="prettyPhoto[iframes]';
(Note that " at the end is missing, because it's already provided in href="").
But if you want to use it for a single link, try
<a href="<?php echo $link; ?>?iframe=true&width=100%&height=100%" rel="prettyPhoto[iframes]" ...
There is just a little problem. If in $link there are parameters in URL, it will fail, because any other param must start with &, and we have ?iframe there. So it's good to check, whetever the ? sign occurs in $link or not.
if (strpos($link, '?') > 0)
$link = $link . '&iframe=true&width=100%&height=100%" rel="prettyPhoto[iframes]';
else
$link = $link . '?iframe=true&width=100%&height=100%" rel="prettyPhoto[iframes]';
Try this
<a href="<?php echo $link ."?iframe=true&width=100%&height=100%\" ". " rel=\"prettyPhoto[iframes]\" "; ?>
for echo use " you can use other varible in this