I have a table called"editedworkhours" that is initially empty. I'm inserting into it addedwh and idnumber based on an if/else condition. Such that: If addedwh is empty (then insertion) else (update, because there is already a value). Now the update part is functioning perfectly(because i manually added values in the table in the database to try the update). However if an idnumber (which is the id) doesn't exist in the table, the insertion doesn't occur. Any suggestions on what could be preventing the if/else condition from functioning accurately?
if(isset($_POST['submit']))
{
$addedhours = $_POST['AddedHours'];
$selectid = $_POST['SelectID'];
$sql1="SELECT addedwh FROM editedworkhours WHERE idnumber='$row[0]'";
$getResult = mysql_query($sql1);
$count = count($getResult);
if(empty($count))
{
$sql="INSERT INTO editedworkhours (IDNumber,AddedWH) VALUES('$selectid','$addedhours')";
}
else
{
$tempname = $row['Field'];
$sql2 = "UPDATE editedworkhours SET AddedWH = AddedWH +'$addedhours' WHERE IDNumber='$selectid'";
$result2 = mysql_query($sql2);
if (isset($result2))
{
}
else
{
echo '<script>swal("Error", "Something went wrong error");</script>';
}
}
}
echo $menu;