A
if ( ( empty($infoA) || empty($infoB) ) && ( !empty($inputA) && !empty($inputB) ) )
{
//add
}
B
if ( ( !empty($infoA) || !empty($infoB) ) && ( empty($inputA) && empty($inputB) ) )
{
//remove
}
C
if ( ( !empty($infoA) || !empty($infoB) ) && ( ($inputA != $infoA) || ($inputB != $infoB) ) )
{
//add
}
So, in order to not repeat the add, we can:
if (A || C)
{
//add
}
elseif(B)
{
//remove
}
Any better logic to be applied here on your option?
Context: I believe it's irrelevant what this should do. I mean, it's a logical question. :s Not sure what to write here... :(
This is for a form: some inputs will come from the database, others from input fields. We are doing some comparisons here.
A context: If the value that comes from the database is empty, and the input fields A and B are NOT empty, do add to database.
B context: If the value that comes from the database is NOT empty, and the input fields A and B are empty, do remove from the database.
C context: If the values that comes from the database are NOT empty, AND the input fieldA !equal infoA or input fieldB NOT equal database value infoB then, do add to the database.
Please advice. MEM