| 41 | | $name=stripslashes($_GET["name"]); |
| 42 | | |
| 43 | | if(!isset($_GET["excludeid"])) $_GET["excludeid"]="0"; |
| 44 | | if(!$_GET["excludeid"]) $_GET["excludeid"]="0"; |
| 45 | | $querystatement="SELECT id FROM ".$_GET["table"]." WHERE id!=".$_GET["excludeid"]." and ".$_GET["field"]."=\"".$_GET["value"]."\";"; |
| 46 | | $queryresult = mysql_query($querystatement,$dblink); |
| 47 | | if(!$queryresult) die($querystatement); |
| 48 | | $numrows=mysql_num_rows($queryresult); |
| | 41 | function isUnique($tablename,$column,$value,$excludeid,$dblink){ |
| | 42 | |
| | 43 | $thereturn=false; |
| | 44 | |
| | 45 | $querystatement="SELECT count(id) AS thecount FROM ".$tablename." WHERE ".$column."=\"".$value."\" AND id!=".$excludeid; |
| | 46 | $queryresult=mysql_query($querystatement,$dblink); |
| | 47 | if($queryresult){ |
| | 48 | $therecord=mysql_fetch_array($queryresult); |
| | 49 | if($therecord["thecount"]==0) |
| | 50 | $thereturn=true; |
| | 51 | } |
| | 52 | |
| | 53 | return $thereturn; |
| | 54 | } |
| | 55 | |
| | 56 | |
| | 57 | $isunique=false; |
| | 58 | |
| | 59 | if(isset($_GET["tdid"]) && isset($_GET["c"]) && isset($_GET["val"]) && isset($_GET["xid"])) { |
| | 60 | $_GET["tdid"]=((int) $_GET["tdid"]); |
| | 61 | $_GET["xid"]=((int) $_GET["xid"]); |
| | 62 | |
| | 63 | $querystatement="SELECT maintable FROM tabledefs WHERE id=".$_GET["tdid"]; |
| | 64 | $queryresult=mysql_query($querystatement,$dblink); |
| | 65 | if($queryresult) |
| | 66 | if($therecord=mysql_fetch_array($queryresult)) |
| | 67 | $isunique=isUnique($therecord["maintable"],$_GET["c"],$_GET["val"],$_GET["xid"],$dblink); |
| | 68 | } |