shopping cart - PHP online store, looping buttons & databases -
so writing code , want make getting data of database using loop. problem got can't seem find way push through value database buttons got. open ideas. !
<!doctype html> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"/> <title>online catalog</title> </head> <body> <form action="" method="get"> <?php session_start(); require('database.php'); echo "<h1><a href=". 'index.php' .">catalog</a></h1> <b id=".cart."><a href=". 'cart.php' .">show cart</a></b>"; if ($result = $connection->query("select * `store`")) { $row_cnt = $result->num_rows; while ($row = $result->fetch_assoc()) { echo "<p> <table> <th> <img src=".$row[img_path].'/'.$row[img_name]."> </th> <td> <h2>". $row[name] ."</h2><br> ". $row[description] ."<br><br> price : ". $row[price] ."$<br> </td> <td > <input type='submit' name='add".$row[id]."' value='add cart'/> </td> </table> </p> "; if(isset($_get['add.$row[id].'])){ $cart=1; if(mysqli_query($connection, "insert `store-project`.`store` (`incart`) values ('$cart')")){ mysqli_close($connection); header("location: cart.php"); } } } $result->close(); } ?> </form> </body> </html>
try use post method in form.
if($_post['add.$row['id'].']){ $insert = "insert store-project.store set incart = '".$cart1."'; mysqli_query($insert); header("location: cart.php"); }
hope helps
Comments
Post a Comment