Help my write a function.
function reportThread() {
global $id;
$result = mysql_query("SELECT is_checked FROM reports WHERE url = '?threadID=$id'");
$r = mysql_fetch_assoc($result);
if ($r['is_checked'] == 0) {
echo "<script type=\"text/javascript\">alert(\"A moderator has been notified.\");</script>";
mysql_query("INSERT INTO reports (url, userID) VALUES ('?threadID=$id', 1)");
} else echo "<script type=\"text/javascript\">alert(\"Theres already a pending report on this thread.\");</script>";
}
What I want to achive is that if theres is a URL that the user reports in the table with is_checked = 0 i want it to say error else i want it to insert!
This will not work for me. It does always insert.
reports:
id, url, is_checked(default 0), userID
i have records...