Same page Hyperlink with PHP - php

I would like to link to another part of a php page. So $x is a value I've pulled from an array that is a hyperlink.
echo "<a href='#{$x}'>{$x}</a>" . " ";
However I am stuck in linking to the target id on the same page.
echo '<a id="$x">' . '<h2>'.strtoupper(str_replace("_", " ",($x))).' ' . 'offers'.'</h2>'.'</a>';
Sure when I hover over the link, it is passing the correct value of $x in the query string, but not linking to the because I am coding the target id part wrong.
Any help appreciated.
Volterony

If you want to visit a ID on on the page use href="#id"
echo '' . '<h2>'.strtoupper(str_replace("_", " ",($x))).' ' . 'offers'.'</h2>'.'';
Improved Code
echo '<h2>'.strtoupper(str_replace("_", " ",($x))). 'offers </h2>';

Related

How to print a variable in href with php?

I'm trying to pass an id in a link href and I need it to be printed in the URL, my code is:
echo " $ville_nom ";
But the id is not print in the url, could you help me with the syntax ?
You have mistake in your usage of echo and your concat was wrong.
The corrected code :
echo "<a href='ville.php?id='".$ville_id."'> $ville_nom ";
When you used the double quote it's not necessary to concat variables to show their content. Be careful: it can be dangerous sometimes.
echo "<a href='ville.php?id=$ville_id'> $ville_nom ";
Try to use this:
echo "<a href='ville.php?id=" . $ville_id . "'>"

Href with skype links is not displayed

I have the following code:
if (!empty($row['skype'])) {
echo "<b>Skype:</b> " . $row['skype'] . " Chat";
}
Unfortunately, this does not display as hyperlink on my website. If I change it to:
if (!empty($row['skype'])) {
echo "<b>Skype:</b> " . $row['skype'] . " Chat";
}
The link is displayed, but it is broken - it leads to www.domain.com/%22skype:venci?chat%22
I have other hrefs in my page like:
echo "<b>E-Mail:</b> " . $row['email'] . "<br />";
and these are displayed correctly, so I'm wondering.. Why is this not working?
I found the issue. It lies within the popover component in bootstrap. Thanks to all guys!
It looks like the popover does not support all href types :)

PHP create Url in mysqli_query while loop for every record

I would like to create a link within a while loop where the anchor link is a record from the query and the href passes a variable from the same query to another page so I only have to create one page that displays information based on the passed variable.
echo "<td>";
echo ''$row['result']''';
echo "</td></tr>";
This link kills my page and return an error.
echo "<td>";
echo ''.$row['result'].'';
echo "</td></tr>";
Should fix your code your quotes are not closed right
Your href string concatenation is incorrect.
It seems like you tried closing your strings and concatenating them halfway through and then stopped. Even with Stack Overflow you can see the string errors.
This is how your href echo should look:
echo '<a href="stats_game.php?idGame=' .$row['idGame'] . '>' . $row['result'] . '</a>';
It works fine for me
echo "<td><a href='stats_game.php?idGame=".$row['idGame']."'>".$row['result']."</a></td>";

Extract part of a link using php?

I am trying to grab the ID of my link from every single one and output it to a db which i will then use to go and scrape the actual page.
So i will grab the id, curl the page link then parse the details.
So far i have my links clickable, it's just trying to get the certain part of my links that is the hard part.
I have tried $_GET['id'] but this won't work as the id's are not in that format.
Here is the way my links are set out:
download.php/1000338/The%20Rise%20and%20Fall%20of%20Legs%20Diamond%20%5B1960%5D.avi.torrent
what i want to grab is the 1000338 part but i want it to do this for every single one and ofcourse they are not the same.
Any help is very much appreciated, thanks.
$link="download.php/1000338/The%20Rise%20and%20Fall%20of%20Legs%20Diamond%20%5B1960%5D.avi.torrent";
$x=explode('/',$link);
$id=$x[1];
demo:http://codepad.viper-7.com/cWYXKe
using your code:
$rss = simplexml_load_file('RSS FEED HERE');
echo '<h1>'. $rss->channel->title . '</h1>';
foreach ($rss->channel->item as $item) {
//echo the link echo '<h2>' . $item->title . "</h2>";
//echo the date echo "<p>" . $item->pubDate . "</p>";
//echo the description echo "<p>" . $item->description . "</p>"
$x=explode('/',$item->link);
$id=$x[1];
}
then use $id any way you like

Using php/mysql to populate href link

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

Categories