php - how to update the price of a product in eshopping -


i m making shopping cart in php & mysql. have problem update price of product. code below. plz tell me m wrong. echo statement not working , boxes products prices displayed.

<?php include("includes/db.php"); include("includes/functions.php");  if(isset($_post['update_price'])){ //print_r($_post['price']);      foreach($_post['price'] $priceup => $prvalue){       echo $sql = "update products set price='$prvalue' serial = '".     $_post['product_data'][$priceup] ."'";     echo $result=mysql_query($sql);}    }                   ?>    <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"        "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">          <html xmlns="http://www.w3.org/1999/xhtml">             <head>           <meta http-equiv="content-type" content="text/html; charset=utf-8" />                 <title>products prices management</title>                   <script language="javascript">                         function update_cart(){              document.form1.command.value='update';                             document.form1.submit();               }                  </script>            <style type="text/css">              <!--             .style3 {         font-family: georgia, "times new roman", times, serif; font-weight: bold; font-style: italic; color: #ff0000;         }         -->             </style>         </head>        <body>         <h1 class="style3">products price management</h1>          <table border="2" cellpadding="2px" width="473">             <?php         $result=mysql_query("select * products");         while($row=mysql_fetch_array($result)){     ?>             <tr>          <input type="hidden" name="product_data[]"  value="<?php echo $row['serial']; ?>" />          <td width="205"><b><?php echo $row['name']?></b></td>          <td width="246"><input type="text" name="price[]" value="<?php echo  $row['price']?>"maxlength="3" size="2" />              </td>               </tr>              <?php                 }                ?>            </table>               <div>     <input type="submit" name="update_price" value="update prices" >            </div>               </body>             </html> 

plz tell me m doing wrong?

first form not getting submitted. forgot place form tags, check here.

      <form  action="<?php echo htmlentities($_server['php_self']); ?>" method="post">       <table border="2" cellpadding="2px" width="473">       <?php       $result=mysql_query("select * products");        while($row=mysql_fetch_array($result)){        ?>       <tr>       <input type="hidden" name="product_data[]"  value="<?php echo $row['serial']; ?>" />       <td width="205"><b><?php echo $row['name']?></b></td>       <td width="246"><input type="text" name="price[]" value="<?php echo  $row['price']?>"maxlength="3" size="2" />          </td>        </tr>        <?php         }         ?>         </table>         <div>        <input type="submit" name="update_price" value="update prices" >        </div>        </form> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -