How to Create Update Products in PHP
Submitted by rinvizle on Tuesday, July 5, 2016 - 17:08.
Hello guys, in this tutorial i will teach you how to create Update Form in every Products in PHP. This simple tutorial updates the products and the quantity of every data of product. Here are the sample script that i will show you.
Process Script for the updating the Products
I hope that you learn in this tutorial. For more source code and tutorials just visit www.sourcecodester.com and don't forget to Like and Share. Thanks.
Sample Code
PHP Script For the proucts list- <?php
- include "connection.php";
- $q="select * from tblprod order by prod_id asc";
- $prid=$rs['prod_id'];
- $prname=$rs['prod_name'];
- $categ=$rs['prod_ctry'];
- $qty=$rs['prod_qty'];
- echo "<tr class='tb1'>";
- echo "<td>".$prid."</td>";
- echo "<td>".$prname."</td>";
- echo "<td>".$categ."</td>";
- echo "<td>".$qty."</td>";
- echo "<td> <a href='edit.php?id=$prid' id='popedit'>Edit</a></td>";
- echo "</tr>";
- }
- ?>
- <?php
- include 'connection.php';
- function edit_product($id,$prid,$prname,$prctry,$prqty){
- $q="update tblprod set prod_id='$prid', prod_name='$prname',prod_ctry='$prctry',prod_qty='$prqty' where prod_id='$prid'";
- echo "<script language='javascript'>
- alert('PRODUCT UPDATED SUCCESSFULLY');
- window.location = 'index.php';
- </script>";
- }
- else{
- echo "<script language='javascript'>
- alert('Error While Updating Product');
- window.location = 'edit.php';
- </script>";
- }
- }
- $prid=$_POST['eprodid'];
- $prname=$_POST['eprodname'];
- $prctry=$_POST['ecategory'];
- $prqty=$_POST['equantity'];
- edit_product('',$prid,$prname,$prctry,$prqty);
- }
- ?>
Add new comment
- 193 views