Sanju Menon February 2016

From POST form saving the record to the mysql db

I have done this many time to get the form POST and saving in a mysql db. I have a form with some data and when i save the button the data should be saved to another table. I have some 350 records to show in the form and when i save it, it should write to another table. But when the records are saved to another table its just saving some 63 records to another table from the form where as the actual record numbers is above 250 records.

My save.php file is as follows:

$size = count($_POST['sl']);
$i = 0;
while ($i < $size) {
    $sl= $_POST['sl'][$i];
    $item_id= $_POST['item_id'][$i];
    $item_name= $_POST['item_name'][$i];

    $query = "INSERT INTO anothertable SET slno = '$sl',item_name = '$item_name',item_id = 
'$item_id' ";
mysql_query($query) or die ("Error in query: $query");

++$i;
}

Is this script fine? Or Am i making any mistake?

The Form script is posted below:

  <?php

   echo "<form name='cart' method='post' action='price_add_save.php?supplier_name=$supplier_name_enc&tender_id=$tender_id' >";?>

  $sql= "(SELECT item_name, item_id, tender_id, slno FROM tender_items WHERE tender_id=$tender_id) order by slno";
  $result = mysql_query($sql) or die($sql."<br/><br/>".mysql_error());

    $i = 0;

     while ($list5 = mysql_fetch_array($result)) {


        echo '<tr>';
        echo "<td width='4%'><input size='1' type='text' id='sl[$i]' name='sl[$i]' value='{$list5['slno']}' readonly/></td>";
        echo "<td width='10%' id='addinput'><input type='text' size='15' name='item_name[$i]' placeholder='{$list5['item_name']}' value='{$list5['item_name']}'></td>";
        echo "<td width='3%'><input size='2' class='item_id' type='text' name='item_id[$i]' value='{$list5['item_id']}' readonly/></td>";

        ++$i;
    }   
    echo '<input type="submit" value="--Save Data--" />';
   ?>

      

Answers


Sanju Menon February 2016

It was basically an issue with max_input_vars in php.ini. I changed from 1000 to 5000..its working fine now. Thank you all..

Post Status

Asked in February 2016
Viewed 3,282 times
Voted 13
Answered 1 times

Search




Leave an answer