I am using array to display the data after user click a button
Here is my code:
$items=array("1234"=>"Iphone 5S","1235"=>"Samsung Galaxy S4");
$proids = $_POST['product_id'];
echo $items[$proids];
Here is the code for products:
<div>
<image src="ip5s.jpg">
<p><font color="blue">  Iphone 5S</font></p>
<p><font color="red">  RM1999</font></p>
<p><form name="addcart" method="post" action="processcart.php">
<input type="submit" name="addtocart" value="Add to cart">
<input type="hidden" name="product_id" value="1234" />
<input type="hidden" name="quantity" value="1" />
</form>
</p>
</div>
<div>
<image src="s4.png">
<p><font color="blue">  Samsung Galaxy S4</font></p>
<p><font color="red">  RM1999</font></p>
<p><form name="addcart" method="post" action="processcart.php" >
<input type="submit" name="addtocart" value="Add to cart">
<input type="hidden" name="product_id" value="1235" />
<input type="hidden" name="quantity" value="1" />
</form>
</p>
</div>
However this will only show one data.For example i click on the add button for Iphone5, it will redirect to page and show me Iphone5. After that i click on Samsung, it will redirect to page and overwrite the Iphone5 and show me Samsung.