I have following data in the table..
+-------------+---------------+--------------+
| activity_id | activity_name | main_unit_id |
+-------------+---------------+--------------+
| 1 | DEA | 67 |
| 2 | DEB | 68 |
| 3 | DEC | 68 |
| 4 | fasdfsadf | 74 |
+-------------+---------------+--------------+
i want to add another activity, but before adding i have to make sure that same activity name is not there against an main_unit_id... I write following query,
$SQL_CHECK_ACTIVITY = mysql_query(
"SELECT count(*) FROM activities " .
"WHERE main_unit_id = '67' and activity_name = 'DEA'"
);
$RESULT_SQL_CHECK_ACTIVITY = mysql_num_rows($SQL_CHECK_ACTIVITY);
echo $RESULT_SQL_CHECK_ACTIVITY;
then it print 1 which means a activity against this project already exists...
$SQL_CHECK_ACTIVITY = mysql_query(
"SELECT count(*) FROM activities " .
"WHERE main_unit_id = '78' and activity_name = 'afsdaf'"
);
$RESULT_SQL_CHECK_ACTIVITY = mysql_num_rows($SQL_CHECK_ACTIVITY);
echo $RESULT_SQL_CHECK_ACTIVITY;
then it print 1 which means a activity against this project already exists... but there is no record in this case....