Hello
I have a data entry page on a website that shows a number of options in columns (size / colour / quantity) for a list of items (rows)
As it turns out the user will not fill in all of the information in one go, they will come to the site on 2 or 3 occassions to fill in different bit of information but in each case they will complete at least one row.
At the moment the code I have enters the data onto the mysql database for all the rows whether the user has entered data or not so I am getting a lot of blank records in the database which is screwing up the data I am getting out ........
so what I want to do it put some sort of if $_POST['quantity'] <1 don't add the record but I don't know the best way to do this or where to put it in the code - the code I have at the moment is
if (isset($_POST['Quantity']))
{
$arr_size = count($_POST['Quantity']);
for ($i=0;$i< $arr_size;$i++)
{
$Quantity = strip_tags(trim($_POST['Quantity'][$i]));
$Colour = strip_tags(trim($_POST['Colour'][$i]));
$Id = ($_POST['Id'][$i]);
$query = "INSERT INTO tblResults (Ref,MRef,SRef,CRef,Quantity,Colour,LoadedBy)
VALUES ('$Ref','$MId','$SRef','$CRef','$Quantity','$Colour','$UserId')";
$result = mysql_query($query)
or die(mysql_error());
} //close for
} //close if
I have tried
if (!empty($POST['Quantity']))
and if ($POST['Quantity'] >= 1)
but neither gives the desired effect, I am still getting records with 0 in the quantity / colour fields.
can anyone suggest how I can improve this code so that it only inserts records when a user has put the data in the row on the website - thanks