Jump to content

Returning to the previous page, in the position of last added product


Recommended Posts

Hello! My problem is a HTML and a PHP one... I don't know if I correctly posted this problem.

In a page with a list of products (domain.php), I've put anchor to each product in this way:

 

<a name="product'.$row['name'].'"></a>

 

One user adds a product into his cart. I have another page who makes the adding operation into MySQL database (add.php). After the product is add into the cart, I want that browser returns in the page with the list of products (domain.php) in the same position of the last added product.

 

Add.php:

 

mysql_query($sql1);
mysql_query($sql2);
$_GET['id_subdomeniu']=$row["id_subdomeniu"];
include("domain.php");
[code]

My code is functioning, but it doesn't determine the browser to return in the position of the last product... I thought to use header("location:domain.php#product'.$name.'" or <echo ...> using the anchor, but in these cases the code doesn't transmit to domain.php the variable $_GET['id_subdomeniu']=$row["id_subdomeniu"]; and I get an error because domain.php don't have the value of $_GET['id_subdomeniu'].

Please, can you help me to solve this problem?

There's no reason you can't simply redirect to the page adding tyhe anchor tag on the end. BUt, if this is the code you are using, it is wrong

header("location:domain.php#product'.$name.'")

You are defining the location in double quotes and then apparently try to add the $name within single quotes.

 

Try this:

header("location:domain.php#product{$name}")

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.