I'm trying to copy the row and insert into same table with new product Id number, in copy_action.php page I'm getting errors said
Undefined offset: 1 in .... line 18
Undefined offset: 1 in .... line 18
Undefined offset: 1 in .... line 18
Insert code is come with array, and i'm not sure why i'm getting errors on line 18 where it said
('$product_name[$i]','$product_category[$i], $product_price[$i]')" or die(mysql_error());
please completely code and see what i missed and how to solve that please!
<?php
include('dbcon.php');
$product_id=$_POST['product_id'];
$product_name = $_POST['product_name'];
$product_category = $_POST['product_category'];
$product_price = $_POST['product_price'];
$N = count($product_id);
for($i=0; $i < $N; $i++)
{
$order = "INSERT INTO product
(product_name, product_category, product_price)
VALUES
('$product_name[$i]','$product_category[$i], $product_price[$i]')" or die(mysql_error());
}
$result = mysql_query($order); //order executes
if($result)
{
echo("
Input data is succeed");
}
else
{
echo("
Input data is fail");
}
?>