Page 1 of 1

Returning to the previous page, in the previous position

Posted: Mon Mar 01, 2010 1:25 pm
by monicao
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:

Code: Select all

 
<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:

Code: Select all

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

Code: Select all

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?

Re: Returning to the previous page, in the previous position

Posted: Mon Mar 01, 2010 2:00 pm
by AbraCadaver
Try:

Code: Select all

header("location: domain.php?id_subdomeniu={$row['id_subdomeniu']}#product{name}");