PHP MySQL eCommerce Admin Panel Tutorial Tutorial

Product

In our previous article, we learned about, How to create a Category Page. Now we have our Products Category. In this free tutorial article, we are going to learn about How to create a Product Page. On the product page, admin or employees are able to create a new Product.

Theory or Requirement

We are creating an e-commerce website similar to Amazon. Our website also supports the various range of products.
Employees are able to add a new product with the following information

  • Product Name: Product Display name 
  • Product Description: A detailed product description.
  • Product Meta Keywords: Keywords information for HTML Meta Keywords.
  • Product Meta Description: A Short description for HTML Meta Description.
  • Stock: Product Available Stock.
  • Price: Product MRP.
  • Offer Price: Offer Price for the product.
  • Max Quantity: Max number of products a customer can buy.
  • Category: Product must belong to at least one category.

Based on above requirement following is the database table structure.
Table Name: tblProduct
Table Columns
ProductID: A unique ID for each product.
ProductDisplayID: A unique random generated string for our product.
ProductName: Name of the Product.
ProductDescription: Product detailed description.
MetaKeyWords: Keywords for HTML Tags
MetaDescription: A Short Description
Stock: Currently available product quantity
Price: Print Price or MRP.
OfferPrice: Discounted price.
MaxQuantity: Max number of quantity a user can add to the cart.

Our product can belong to multiple categories so for storing product and category mapping database table.
Table Name: tblProductCategoryMapping
Table Columns
ProductID: Product ID.
CategoryID: Category ID.
Primary Key: ProductID and CategoryID Combination. It helps us to avoid duplicate entries.

Database Changes

Following are the Create table statement for tblProduct and tblProductCategoryMapping.

Code

<pre class="brush:as3;">
CREATE TABLE tblProduct(
	ProductID			BIGINT PRIMARY KEY AUTO_INCREMENT,
    ProductDisplayID	VARCHAR(100) UNIQUE,
    ProductName			VARCHAR(200) ,
    ProductDescription	TEXT ,
    MetaKeyWords		VARCHAR(200),
    MetaDescription		VARCHAR(400),
    Stock				BIGINT,
    Price				FLOAT,
    OfferPrice			FLOAT,
    MaxQuantity			INT
);</pre>

<p>&nbsp;</p>
CREATE TABLE tblProduct(
    ProductID            BIGINT PRIMARY KEY AUTO_INCREMENT,
    ProductDisplayID    VARCHAR(100) UNIQUE,
    ProductName            VARCHAR(200) ,
    ProductDescription    TEXT ,
    MetaKeyWords        VARCHAR(200),
    MetaDescription        VARCHAR(400),
    Stock                BIGINT,
    Price                FLOAT,
    OfferPrice            FLOAT,
    MaxQuantity            INT
);
CREATE TABLE tblProductCategoryMapping
(
    ProductID            BIGINT,
    CategoryID            BIGINT,
    PRIMARY KEY (ProductID,CategoryID),
    FOREIGN KEY (ProductID) REFERENCES tblProduct(ProductID),
    FOREIGN KEY (CategoryID) REFERENCES tblCategory(CategoryID)
);

 

Database diagram with above changes.

PHP Changes

Our Database is ready. Now we need to create a Product page. Let's create a copy of PlainPage.php file and save it with name Product.php. Add a new entry in LeftMenu.php for our Product Page, so we can access Product page from the left menu.

Note: In this article, we are using files which we created in our Category tutorial article. If you want to know about all the files please check this article.

Next, we need to edit Product.php file. Include SessionCheck.php and WebSiteConfig.php at the top. We need to add our product to a category. Let's first list down all the categories. We will create a checkbox for each category. Assume the checkbox group name is "cbCategory". Open Category.php and copy code to fetch the Category from the database. We need to modify the code in the while loop. Following is the code copy and add it to the top.

Code

<pre class="brush:as3;">
require_once &#39;SessionCheck.php&#39;;
require_once &#39;WebSiteConfig.php&#39;;
$CategoryOptions=&quot;&quot;;
$SaveMSG=&quot;&quot;;
$MySQLConnection = new mysqli(DB_SERVER,DB_USER,DB_PASSWORD,DB_DATABASE_NAME);
if ($MySQLConnection-&gt;connect_error) {
    die(&quot;Connection failed: &quot; . $MySQLConnection-&gt;connect_error);
}
$SQLQuery = &quot;SELECT CategoryID,CategoryName FROM tblCategory;&quot;;
$SQLPrepare = $MySQLConnection-&gt;prepare($SQLQuery);
$SQLPrepare-&gt;execute();
$SQLResult = $SQLPrepare-&gt;get_result();
while ($SQLRow = $SQLResult-&gt;fetch_assoc()) {
    $CategoryOptions = $CategoryOptions
    .&quot;&lt;div class=\&quot;checkbox\&quot;&gt;&lt;label&gt;&lt;input name=\&quot;cbCategory[1][]\&quot; type=\&quot;checkbox\&quot; value=\&quot;&quot;
    .$SQLRow[&quot;CategoryID&quot;].&quot;\&quot;&gt; &quot;
    .$SQLRow[&quot;CategoryName&quot;].&quot;&lt;/label&gt;&lt;/div&gt;&quot;;
}</pre>

<p>&nbsp;</p>

Next we need to create new product form. Following is the code for New Product form.

Code

<pre class="brush:as3;">
&lt;form action=&quot;SaveProduct.php&quot; method=&quot;post&quot; class=&quot;form-horizontal form-label-left&quot; &gt;
&lt;div class=&quot;row&quot;&gt;
  &lt;div class=&quot;col-md-4 col-sm-6 col-xs-12&quot;&gt;
    &lt;div style=&quot;height:200px&quot;&gt;
        &lt;?php 
          echo $CategoryOptions;
        ?&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;col-md-8 col-sm-6 col-xs-12&quot;&gt;
    &lt;div class=&quot;form-group&quot;&gt;
      &lt;label class=&quot;control-label col-md-3 col-sm-3 col-xs-12&quot; for=&quot;tbProductName&quot;&gt;Product Name &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
      &lt;div class=&quot;col-md-6 col-sm-6 col-xs-12&quot;&gt;
        &lt;input type=&quot;text&quot; id=&quot;tbProductName&quot; name=&quot;tbProductName&quot; placeholder=&quot;Enter Product Name&quot; class=&quot;form-control&quot; /&gt;
      &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class=&quot;form-group&quot;&gt;
      &lt;label class=&quot;control-label col-md-3 col-sm-3 col-xs-12&quot; for=&quot;tbPrice&quot;&gt;Price &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
      &lt;div class=&quot;col-md-6 col-sm-6 col-xs-12&quot;&gt;
        &lt;input type=&quot;number&quot; id=&quot;tbPrice&quot; name=&quot;tbPrice&quot; placeholder=&quot;Enter Product Price&quot; class=&quot;form-control&quot; /&gt;
      &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class=&quot;form-group&quot;&gt;
      &lt;label class=&quot;control-label col-md-3 col-sm-3 col-xs-12&quot; for=&quot;tbOfferPrice&quot;&gt;Offer Price &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
      &lt;div class=&quot;col-md-6 col-sm-6 col-xs-12&quot;&gt;
        &lt;input type=&quot;number&quot; id=&quot;tbOfferPrice&quot; name=&quot;tbOfferPrice&quot; placeholder=&quot;Enter Product Offer Price&quot; class=&quot;form-control&quot; /&gt;
      &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class=&quot;form-group&quot;&gt;
      &lt;label class=&quot;control-label col-md-3 col-sm-3 col-xs-12&quot; for=&quot;tbStock&quot;&gt;Stock &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
      &lt;div class=&quot;col-md-6 col-sm-6 col-xs-12&quot;&gt;
        &lt;input type=&quot;number&quot; id=&quot;tbStock&quot; name=&quot;tbStock&quot; placeholder=&quot;Enter Product Stock&quot; class=&quot;form-control&quot; /&gt;
      &lt;/div&gt;
    &lt;/div&gt;


    &lt;div class=&quot;form-group&quot;&gt;
      &lt;label class=&quot;control-label col-md-3 col-sm-3 col-xs-12&quot; for=&quot;tbMaxAllowQuantity&quot;&gt;Max Allow Quantity for Each Order &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
      &lt;div class=&quot;col-md-6 col-sm-6 col-xs-12&quot;&gt;
        &lt;input type=&quot;number&quot; id=&quot;tbMaxAllowQuantity&quot; name=&quot;tbMaxAllowQuantity&quot; placeholder=&quot;Enter Product Max Quantity&quot; class=&quot;form-control&quot; /&gt;
      &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class=&quot;form-group&quot;&gt;
      &lt;label class=&quot;control-label col-md-3 col-sm-3 col-xs-12&quot; for=&quot;tbMetaKeyWords&quot;&gt;Meta Key Words &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
      &lt;div class=&quot;col-md-6 col-sm-6 col-xs-12&quot;&gt;
        &lt;input type=&quot;text&quot; id=&quot;tbMetaKeyWords&quot; name=&quot;tbMetaKeyWords&quot; placeholder=&quot;Enter Meta Key Words&quot; class=&quot;form-control&quot; /&gt;
      &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class=&quot;form-group&quot;&gt;
      &lt;label for=&quot;message&quot;&gt;Meta Description (100 max) :&lt;/label&gt;
      &lt;textarea id=&quot;taMetaDescription&quot; required=&quot;required&quot; class=&quot;form-control&quot; name=&quot;taMetaDescription&quot; 
        maxlenght=&quot;100&quot;&gt;&lt;/textarea&gt;
    &lt;/div&gt;

    &lt;div class=&quot;form-group&quot;&gt;
      &lt;label for=&quot;message&quot;&gt;Product Description (1000 max) :&lt;/label&gt;
      &lt;textarea id=&quot;taProductDescription&quot; required=&quot;required&quot; class=&quot;form-control&quot; name=&quot;taProductDescription&quot; 
        maxlenght=&quot;1000&quot;&gt;&lt;/textarea&gt;
    &lt;/div&gt;
    &lt;div class=&quot;form-group&quot;&gt;
        &lt;div class=&quot;col-md-6 col-sm-6 col-xs-12 col-md-offset-3&quot;&gt;
        &lt;button class=&quot;btn btn-primary&quot; type=&quot;submit&quot;&gt;Save&lt;/button&gt;
        &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class=&quot;form-group&quot;&gt;
        &lt;div class=&quot;col-md-6 col-sm-6 col-xs-12 col-md-offset-3&quot;&gt;
        &lt;?php echo $SaveMSG; ?&gt;  
        &lt;/div&gt;
    &lt;/div&gt;

  &lt;/div&gt;
&lt;/div&gt;
&lt;/form&gt;</pre>

<p>&nbsp;</p>
<form action="SaveProduct.php" method="post" class="form-horizontal form-label-left" >
  <input type="hidden" id="ihProductID" name="ihProductID" value="-1" />
  <input type="hidden" id="ihProductDID" name="ihProductDID" value="" />
<div class="row">
  <div class="col-md-4 col-sm-6 col-xs-12">
    <div style="height:200px">
        <?php 
          echo $CategoryOptions;
        ?>
    </div>
  </div>
  <div class="col-md-8 col-sm-6 col-xs-12">
    <div class="form-group">
      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="tbProductName">Product Name <span class="required">*</span></label>
      <div class="col-md-6 col-sm-6 col-xs-12">
        <input type="text" id="tbProductName" name="tbProductName" placeholder="Enter Product Name" class="form-control" />
      </div>
    </div>

    <div class="form-group">
      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="tbPrice">Price <span class="required">*</span></label>
      <div class="col-md-6 col-sm-6 col-xs-12">
        <input type="number" id="tbPrice" name="tbPrice" placeholder="Enter Product Price" class="form-control" />
      </div>
    </div>

    <div class="form-group">
      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="tbOfferPrice">Offer Price <span class="required">*</span></label>
      <div class="col-md-6 col-sm-6 col-xs-12">
        <input type="number" id="tbOfferPrice" name="tbOfferPrice" placeholder="Enter Product Offer Price" class="form-control" />
      </div>
    </div>

    <div class="form-group">
      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="tbStock">Stock <span class="required">*</span></label>
      <div class="col-md-6 col-sm-6 col-xs-12">
        <input type="number" id="tbStock" name="tbStock" placeholder="Enter Product Stock" class="form-control" />
      </div>
    </div>


    <div class="form-group">
      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="tbMaxAllowQuantity">Max Allow Quantity for Each Order <span class="required">*</span></label>
      <div class="col-md-6 col-sm-6 col-xs-12">
        <input type="number" id="tbMaxAllowQuantity" name="tbMaxAllowQuantity" placeholder="Enter Product Max Quantity" class="form-control" />
      </div>
    </div>

    <div class="form-group">
      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="tbMetaKeyWords">Meta Key Words <span class="required">*</span></label>
      <div class="col-md-6 col-sm-6 col-xs-12">
        <input type="text" id="tbMetaKeyWords" name="tbMetaKeyWords" placeholder="Enter Meta Key Words" class="form-control" />
      </div>
    </div>

    <div class="form-group">
      <label for="message">Meta Description (100 max) :</label>
      <textarea id="taMetaDescription" required="required" class="form-control" name="taMetaDescription" 
        maxlenght="100"></textarea>
    </div>

    <div class="form-group">
      <label for="message">Product Description (1000 max) :</label>
      <textarea id="taProductDescription" required="required" class="form-control" name="taProductDescription" 
        maxlenght="1000"></textarea>
    </div>
    <div class="form-group">
        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
        <button class="btn btn-primary" type="submit">Save</button>
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
        <?php echo $SaveMSG; ?>  
        </div>
    </div>

  </div>
</div>
</form>

 

In our new product form, we have two columns. On left, we have all the categories checkboxes. On right, we have all the fields for the new product. On form submit user will redirect to "SaveProduct.php".

Note: Where are the options for the image? We want to upload multiple images for a single product.  So we have a separate section for image upload.

When a user clicks on Save button user will redirect to "SaveProduct.php". Create the file and add "<?php var_dump($_POST); ?>" code. Fill the new product form and click on save button.

Following is the output for var_dump.
array(9) { ["cbCategory"]=> array(1) { [1]=> array(2) { [0]=> string(1) "5" [1]=> string(1) "7" } } ["tbProductName"]=> string(8) "iPhone X" ["tbPrice"]=> string(6) "100000" ["tbOfferPrice"]=> string(4) "9999" ["tbStock"]=> string(1) "1" ["tbMaxAllowQuantity"]=> string(1) "1" ["tbMetaKeyWords"]=> string(12) "iPhone,Apple" ["taMetaDescription"]=> string(39) "Buy a new iPhone X with heavy discount." ["taProductDescription"]=> string(34) "iPhone X Ram, Screen Size, Battery" }

Save all this information into the database. Following is the final code SaveProduct.php

Code

<pre class="brush:as3;">
&lt;?php 
    /* Login Status Check  */
    require_once &#39;SessionCheck.php&#39;;
    require_once &#39;WebSiteConfig.php&#39;;
    $Result=0;
    /* Check if Form is not empty  */
    if(
        isset($_POST[&quot;ihProductID&quot;])
        &amp;&amp; isset($_POST[&quot;ihProductDID&quot;])
        &amp;&amp; isset($_POST[&quot;cbCategory&quot;])
        &amp;&amp; isset($_POST[&quot;tbProductName&quot;])
        &amp;&amp; isset($_POST[&quot;tbPrice&quot;])
        &amp;&amp; isset($_POST[&quot;tbOfferPrice&quot;])
        &amp;&amp; isset($_POST[&quot;tbStock&quot;])
        &amp;&amp; isset($_POST[&quot;tbMaxAllowQuantity&quot;])
        &amp;&amp; isset($_POST[&quot;tbMetaKeyWords&quot;])
        &amp;&amp; isset($_POST[&quot;taMetaDescription&quot;])
        &amp;&amp; isset($_POST[&quot;taProductDescription&quot;])
    )
    {
        $ProductID = intval($_POST[&quot;ihProductID&quot;]);
        $ProductDisplayID=$_POST[&quot;ihProductDID&quot;];
        $Category = $_POST[&quot;cbCategory&quot;];
        var_dump($Category);
        $ProductName = $_POST[&quot;tbProductName&quot;];
        $Price = floatval($_POST[&quot;tbPrice&quot;]);
        $OfferPrice = floatval($_POST[&quot;tbOfferPrice&quot;]);
        $Stock = intval($_POST[&quot;tbStock&quot;]);
        $MaxQuantity = intval($_POST[&quot;tbMaxAllowQuantity&quot;]);
        $MetaKeyWords = $_POST[&quot;tbMetaKeyWords&quot;];
        $MetaDescription = $_POST[&quot;taMetaDescription&quot;];
        $ProductDescription = $_POST[&quot;taProductDescription&quot;];
        $MySQLConnection = new mysqli(DB_SERVER,DB_USER,DB_PASSWORD,DB_DATABASE_NAME);
        // Check connection for error
        if ($MySQLConnection-&gt;connect_error) {
            die(&quot;Connection failed: &quot; . $MySQLConnection-&gt;connect_error);
        }
        $SQLPrepare=null;
        if($ProductID&gt;0)
        {
            $SQL = &quot;UPDATE `tblProduct` SET `ProductName`=?,&quot;
            .&quot;`ProductDescription`=?,`MetaKeyWords`=?,`MetaDescription`=?&quot;
            .&quot;,`Stock`=?,`Price`=?,`OfferPrice`=?,`MaxQuantity`=? WHERE ProductID=?&quot;;
            $SQLPrepare = $MySQLConnection-&gt;prepare($SQLQuery);
            $SQLPrepare-&gt;bind_param(&quot;ssssiddii&quot;,$ProductName,$ProductDescription,$MetaKeyWords
            ,$MetaDescription,$Stock,$Price,$OfferPrice,$MaxQuantity,$ProductID );
            $SQLPrepare-&gt;execute();
            $SQL=&quot;DELETE FROM tblProductCategoryMapping WHERE ProductID=?&quot;;
            $SQLPrepare = $MySQLConnection-&gt;prepare($SQLQuery);
            $SQLPrepare-&gt;bind_param(&quot;i&quot;,$ProductID );
            $SQLPrepare-&gt;execute();
        }
        else{
            $Characters = &#39;0123456789abcdefghijklmnopqrstuvwxyz&#39;;
            $ProductDisplayID = &#39;&#39;;
            for ($i = 0; $i &lt; 20; $i++) {
                $ProductDisplayID = $Characters[rand(0, strlen($Characters))];
            }
            $SQL =&quot;INSERT INTO `tblProduct`(`ProductID`, `ProductDisplayID`, `ProductName`, `ProductDescription`, `MetaKeyWords`, `MetaDescription`, `Stock`, `Price`, `OfferPrice`, `MaxQuantity`) &quot;
            .&quot;VALUES (null,?,?,?,?,?,?,?,?,?)&quot;;
            $SQLPrepare = $MySQLConnection-&gt;prepare($SQLQuery);
            $SQLPrepare-&gt;bind_param(&quot;sssssiddi&quot;,$ProductDisplayID,$ProductName,$ProductDescription,$MetaKeyWords
            ,$MetaDescription,$Stock,$Price,$OfferPrice,$MaxQuantity);
            $SQLPrepare-&gt;execute();    
        }
        if($ProductID&gt;0)
        {
            $Result=1;
        }
        else{
            $Result=-1;
        }
    }
    //echo $Result;
    header(&quot;Location: Product.php?ID=&quot;.$ProductID.&quot;&amp;S=&quot;.$Result);
?&gt;
</pre>

<p>&nbsp;</p>
<?php 
    /* Suppress all error */
    error_reporting(1);
    /* Login Status Check  */
    require_once 'SessionCheck.php';
    require_once 'WebSiteConfig.php';
    $Result=0;
    /* Check if Form is not empty  */
    //var_dump($_POST);
    if(
        isset($_POST["ihProductID"])
        && isset($_POST["ihProductDID"])
        && isset($_POST["cbCategory"])
        && isset($_POST["tbProductName"])
        && isset($_POST["tbPrice"])
        && isset($_POST["tbOfferPrice"])
        && isset($_POST["tbStock"])
        && isset($_POST["tbMaxAllowQuantity"])
        && isset($_POST["tbMetaKeyWords"])
        && isset($_POST["taMetaDescription"])
        && isset($_POST["taProductDescription"])
    )
    {
        $ProductID = intval($_POST["ihProductID"]);
        $ProductDisplayID=$_POST["ihProductDID"];
        $Category = $_POST["cbCategory"];
        $ProductName = $_POST["tbProductName"];
        $Price = floatval($_POST["tbPrice"]);
        $OfferPrice = floatval($_POST["tbOfferPrice"]);
        $Stock = intval($_POST["tbStock"]);
        $MaxQuantity = intval($_POST["tbMaxAllowQuantity"]);
        $MetaKeyWords = $_POST["tbMetaKeyWords"];
        $MetaDescription = $_POST["taMetaDescription"];
        $ProductDescription = $_POST["taProductDescription"];
        $MySQLConnection = new mysqli(DB_SERVER,DB_USER,DB_PASSWORD,DB_DATABASE_NAME);
        // Check connection for error
        if ($MySQLConnection->connect_error) {
            die("Connection failed: " . $MySQLConnection->connect_error);
        }
        $SQLPrepare=null;
        if($ProductID>0)
        {
            $SQL = "UPDATE `tblProduct` SET `ProductName`=?,"
            ."`ProductDescription`=?,`MetaKeyWords`=?,`MetaDescription`=?"
            .",`Stock`=?,`Price`=?,`OfferPrice`=?,`MaxQuantity`=? WHERE ProductID=?";
            $SQLPrepare = $MySQLConnection->prepare($SQL);
            $SQLPrepare->bind_param("ssssiddii",$ProductName,$ProductDescription,$MetaKeyWords,$MetaDescription,$Stock,$Price,$OfferPrice,$MaxQuantity,$ProductID );
            $SQLPrepare->execute();
            $SQL="DELETE FROM tblProductCategoryMapping WHERE ProductID=?";
            $SQLPrepare = $MySQLConnection->prepare($SQLQuery);
            $SQLPrepare->bind_param("i",$ProductID );
            $SQLPrepare->execute();

        }
        else{
            $Characters = '0123456789abcdefghijklmnopqrstuvwxyz';
            $ProductDisplayID = '';
            for ($i = 0; $i < 20; $i++) {
                $ProductDisplayID = $ProductDisplayID.$Characters[rand(0, strlen($Characters))];
            }
            $SQL ="INSERT INTO `tblProduct`(`ProductID`, `ProductDisplayID`, `ProductName`, `ProductDescription`, `MetaKeyWords`, `MetaDescription`, `Stock`, `Price`, `OfferPrice`, `MaxQuantity`) "
            ."VALUES (null,?,?,?,?,?,?,?,?,?)";
            $SQLPrepare = $MySQLConnection->prepare($SQL);
            $SQLPrepare->bind_param("sssssiddi",$ProductDisplayID,$ProductName,$ProductDescription,$MetaKeyWords,$MetaDescription,$Stock,$Price,$OfferPrice,$MaxQuantity);
            $SQLPrepare->execute();    
            $ProductID=$MySQLConnection->insert_id;
            //var_dump($MySQLConnection->error);
        }
        if($ProductID>0)
        {
            for($i=0;$i<count($Category[1]);$i++)
            {
                $SQL ="INSERT INTO `tblProductCategoryMapping`(`ProductID`, `CategoryID`) VALUES (?,?)";
                $SQLPrepare = $MySQLConnection->prepare($SQL);
                $SQLPrepare->bind_param("ii",$ProductID,intval($Category[1][$i]));
                $SQLPrepare->execute();
            }
            $Result=1;
        }
        else{
            $Result=-1;
        }
    }
    header("Location: Product.php?ID=".$ProductID."&S=".$Result);
?>

 

Our product is saved successfully. What is next we need to list down all the products.

...

About The Author

Hello, I am Mayank Sanghvi I am primarily a BI developer with experience in MSBI and Cognos BI Suit. Also having interest in various other technologies such as Android, Java, C#, ASP .NET and other. I enjoy learning new technologies and share my experience with others.

0 Comments
Leave A Comment

Please login to post your valuable comments.

add