As you can see, i have this page where there is the 'add to cart' button on each table row. Lets say i click 'add to cart' for the table row where product id is 1, i would want the productid, productname, cartquantity to be transferred to the shopping cart on another webpage. is it possible?
okay so as you can see i would like to add product id 1 to my cart with quantity 3. But when i pressed add to cart
It always runs to my last productid which is shofffwef and adds it to the cart instead. Not sure what is going wrong :(
Here is my sql code for the add to cart button
if(isset($_POST['insert'])){ //$_POST[X] X = name of textbox (***You got to do this In BASHOP) take note the productname.
$queryinsert = "insert into cart(productid,productname,cartquantity,amount) SELECT productid,productname,'$_POST[cartquantity]', '50' FROM product WHERE productid='$_POST[hidden]'";
mysqli_query($dbconn,$queryinsert);
}
And here is my code to show the table as in the first picture.
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>"."<input type = 'text' name='productid' value=". $row['productid'] ."></td>";
echo "<td>"."<input type = 'text' name='productname' value=". $row['productname'] ."></td>";
echo "<td>" . $row['retailprice'] . "</td>";
echo "<td>" . $row['pointsformula'] . "</td>";
echo "<td>"."<button type='button' class='quantityaddsub' id='sub' onclick='quantitysub(".$row['productid'].")'>-</button>".
"<input type='text' class='quantity' name='cartquantity' id='quantity".$row['productid']."' value=1>".
"<button type='button' class='quantityaddsub' id='add' onclick='quantityadd(".$row['productid'].")'>+</button>".
"<input type='hidden' name='hidden' value=".$row['productid']."></td>";
echo "<td>" . "<input type='submit' name='insert' value='Add To Cart'" . "></td>";
echo "</tr>";
}
echo "</table>";
I've searched everywhere but couldnt find a solution, please help me thanks!