If there exists a row in the table FINES with the required value then I just want to update the fields Else I want to add a new row in the table.
if (mysql_query("SELECT EXISTS(SELECT * FROM fines WHERE SId='$sid' AND Semester='$sem')")>=1)
mysql_query("UPDATE fines SET fines.TFine=fines.TFine+'$fine' WHERE SId='$sid' AND Semester='$sem'");
else
mysql_query("INSERT INTO fines(SId, Semester, TFine, Flag) VAlUES('$sid','$sem', '$fine', 0)");
But the if condition is not working!! Please help