num(auto_incrementing primary key)
area(text)
month(text) <--filled with a variable displaying the month submitted
percent(text)
stat(text)
what I want to do is do a check to see if a record already for a specific area exist for the present month. If no record for the specific area exist for the present month allow the user data to be posted to the database...if one does exist say "data for area already exist for this month" and post nothing.
what i have tried is this
Code: Select all
$query = mysql_query("SELECT Month, Area FROM data WHERE Month ='$DMonth' AND WHERE Area ='$areaSelected'");
$numrows = mysql_num_rows($query);
if ($numrows!=0)
{
while ($row = mysql_fetch_assoc($query))
{
$dbMonth = $row['month'];
$dbArea = $row['area'];
}
if ($DMonth==$dbMonth&&$areaReported==$dbArea)
{
mysql_query("INSERT INTO $table_name (Month, Area, percent, stat)
values ('{$Dmonth}',
'{$areaReported}',
'{$percent}',
'{$stat}')");
}
else {
$display_block.="<p style=\"color:red;\">A Report for this $areaReported has already been submitted for this Month</p>";
}
mysql_num_rows() expects parameter 1 to be resource, boolean given