Greetings,
I'm building a very basic form and one of the checks I want to preform is far more difficult for me than I would have imagined. I am not very proficient (at all) with php, any help would be extremely appreciated.
All I am trying to do is add a test/check with an error that the end user would see if they are trying to 'check out' a unit number that has already been checked out and has not been flagged as not 'returned'. Here is the snippet in question:
$checkunitid = $_POST['uniid'];
//checkexists($checkunitid);
$q="select unit_id from check_in_out where `returned` = 'N' and unit_id = '" . $uniid . "'"
function checkexists() {
$result = mysql_query($q) or die(mysql_error());
if($row = mysql_fetch_array($result)) {
return 1;
}
return 0;
}
if (checkexists()) {
echo "<font size=7 color=red>record exists</font>";
exit();
}