here i am trying to pass the id as parameter for next page using php.
I am retrieving values from database and i have id as a primary key. i want to pass the id for next page. but when i pass the parameter through URL its not appearing on url. how can i do this?
here is what i have done.
echo "<a href='product-des.php?'". $row["product_id"].">";
here the URL is visible till.php but i am not able to see any id after that.
what am i doing wrong here... how can i do this?
To pass parameter
echo '<a href="product-des.php?pro_id='. $row["product_id"].'">';
To get parameter:
echo $_GET['pro_id'];
this
echo "<a href='product-des.php?'". $row["product_id"].">";
should be like this
echo "<a href='product-des.php?product_id=".$row['product_id']'>."'" >Product Name</a>";
try this
Related
What is the correct way to echo a link to another page in php? I have seen this used but it doesn't work?
echo "<p><a href=\"link\">";
Html in PHP
<?php
echo "<a href='$link'>The Link You Want</a>";
?>
Php in Html
Link
It seems like your question was already answered in How to create a link to another PHP page
Index Page
Page 2
If you need to pass a value -
Link that pass the value 1
You would do it like this:
print("<a href='your_target'></a>");
Or if you want to print the code and not the link:
print(htmlspecialchars("<a href='your_target'></a>"));
try this:
<a href='<?php echo "the_page_you_want.php" ?>'>link_text</a>
I have a URL with a parameter
www.url.com/page.php?n=name
Now, within a page.php I need to create a hyperlink that works with that parameter. I now have
<a href="page2.php?a=param2&n=<?php $_GET["n"] ?>" >
but this does not work and the URL shows with empty parameter "n":
http://www.url.com/page2.php?a=param2&n=
Could you please help me to pass that parameter in the hyperlink? Kindly thank you in advance.
You need to do <?php echo $_GET["n"] ?>
The echo actually prints it into the code. You were just calling it.
You need to echo the PHP out so it is echoed out to the HTML, and is then in the source code.
Like so:
<a href="page2.php?a=param2&n=<?php echo $_GET["n"] ?>" >
I am using Dreamweaver and would like to add multiple parameters to my my link. Right now I have one parameter which works fine, but I would like to add multiple parameters to the same link, how do I do that?
The code to the link is as follows:
<a href="Patient.php?Patient=<?php echo
$row_Patienter['Patient']; ?>">Visa</a>
This does links to another page's Recordset.
My question is:
How do I add multiple parameters to the same link? How would it look like?
You can separate parameters by adding a & at the end of each parameter.
Something like:
http://www.domain.com?parameter1=value1¶meter2=value2
But in your case I would recommend to do it like this:
<?php
echo "<a href='patien.php?parameter1=".$value1."¶meter2=".$value2."'>Link</a>";
?>
You add extra parameters by starting with ? and adding & each time you start a new parameter. Remember in HTML to use &
Visa
<a href="bar.php?foo=<php echo $foo; ?>&bar=<?php echo $bar; ?>">
or whatever the values are. Better use echo, not sure what you wrote works
I am working with some anchor tags in HTML where i need to carry over some arguments from the first url to the second url
My Link
My current URL is - oldpage.html?arg=value
But the "My Link" redirects to -
newpage.html
and not
newpage.html?arg=value
How do i carry over the value of arg ?
If you want to just copy a known variable over, it's as simple as
<?php echo "My Link" ?>
and then oldpage.html?arg=value would produce a link to newpage.html?arg=value.
However, if you want to pass over the entire query string, you can achieve this with the $_SERVER["QUERY_STRING"] variable.
<?php echo "My Link" ?>
This will propagate the entire query string to the new page. So if you accessed the current page with oldpage.html?arg=value&color=green, the link would point to newpage.html?arg=value&color=green.
Alternatively you could use http_build_query, allowing you to add extra parameters or modify the existing query string as you see fit.
<?php echo "My Link" ?>
Using this, navigating to the current page as oldpage.html?arg=value would produce a link to newpage.html?arg=value&foo=bar.
My Link
Or you could do this:
My Link
But that is only if your server allows you to use SERVER variables.
here is an existing link
<a class="link-item" href="{#url_site#}/plongee-{$post.nom_pays|sluggable}/{$post.nom_forfait|sluggable}-{$post.id_forf}">Voir l'offre</a>
I am trying to pass a variable to the next page.
I have added:
<a class="link-item" href="{#url_site#}/plongee-{$post.nom_pays|sluggable}/{$post.nom_forfait|sluggable}-{$post.id_forf}?test=test">Voir l'offre</a>
the next page url is
http://dev.amv-voyages.fr/plongee-egypte/dune-sejour-plongee-petit-budget-safaga-sans-vols-1387?test=test
but
echo '<pre>get';
print_r($_GET);
echo '</pre>';
returns empty.
Please help :)
<a class="link-item" href="{#url_site#}/plongee-{$post.nom_pays|sluggable}/{$post.nom_forfait|sluggable}-{$post.id_forf}&test=test">Voir l'offre</a>
Please try this as already there are multiple slashes it means in the rewrite rule already the '?' is used to take the first parameter so all other parameters should use '&' after the first one.