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> 

here database

and here how looks

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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -