I have a php code that updates the value in 2 tables and I used left join. It works but it keeps on skipping the first condition and always enters the second condition. I have no idea on mysql injection so please advice if my code is prone to mysql injection.
elseif ($_POST['check'])
{
if ($row[typeofdog] = 'Labrador')
{
$id = $_POST['data'];
$count = count($id);
for($i=0;$i<$count;$i++)
{
$sql = "UPDATE animals LEFT JOIN treats ON animals.style = treats.style SET animals.bone = bone - treats.total, treats.status = 'Approved' WHERE treats.id='$id[$i]'";
$result = mysql_query($sql);
}
if($result){header("location:login_success.php");}
}
else
{
$id = $_POST['data'];
$count = count($id);
for($i=0;$i<$count;$i++)
{
$sql = "UPDATE animals LEFT JOIN treats ON animals.style = treats.style SET animals.chunks = chunks - treats.total, treats.status = 'Approved' WHERE treats.id='$id[$i]'";
$result = mysql_query($sql);
}
if($result){header("location:login_success.php");}
}
}