<?php
include('../include/session.php');


$list_type = $_POST['list_RadioGroup'];
$list_name = $_POST['preset_name_text'];
$line_num = $_POST['line_num'];


$table_name = $_SESSION['db_prefix']."_preset_list";
$delete_query = "DELETE FROM $table_name WHERE  preset_list_name = '".$list_name."' "; 
execsql($delete_query);


$i=0;
while ($i<$line_num) {
if (isset($_POST['line_checkbox'.$i])) {

$store_item_id = $_POST['store_item_id'.$i];
$quantity = $_POST['quantity_text'.$i];	

if(isset($_POST['line_checkbox'.$i]) ) {
$table_name = $_SESSION['db_prefix']."_preset_list";
$list_query = "INSERT INTO $table_name ( list_type, preset_list_name, store_item_id, preset_quantity) VALUES ('".$list_type."', '".$list_name."', '".$store_item_id."', '".$quantity."' )";
execsql($list_query);
}
};
$i++;
}
?>

<script language="javascript" type="text/javascript">
          window.location="user_list.php";
</script>