Guest_imported
New member
- Jan 1, 1970
- 0
Ok i have 3 tables that i'm querying from.
All three tables have a common column, RTA. Initially i was going to use this as referential integrity, but since mysql doesn't handle referential integrity (least I can't figure out how to do it if it does) I'm attempting to use php to help me out. This is a small application and more for test purposes than anything else. Ok enough background, here is the question.
User enters information from a page into a text field named "rga".
I want to check that this number ($rga) = an RTA number in the main table BEFORE inserting the rest of the information from the page. If there is not an RTA number that equals $rga then I want it to die.
I have this in my page...
$res = mysql_query("SELECT RTA FROM maindcp WHERE RTA = '$rga'"
or die("RTA doesn't exist"
It continues the process regardless if the RMA does or doesn't exist. It either returns a value or returns an empty set, and if i'm correct, an empty set is still "true" so it continues on with the rest of the script.
I then put this after the query but it still continues on-- i don't know if this is even remotely close to what it should be:
$res = mysql_query("SELECT RTA FROM maindcp WHERE RTA = '$rga'"
or die("RTA doesn't exist"
if ($res = $rga) {
} else {print "rta doesn't exist";}
and again it just continues on thru the script and doesn't even blink.
What I want is for it to stop if the number in $rga is not in the maindcp table's RTA column. How could I accomplish this? thanx!
Nico
All three tables have a common column, RTA. Initially i was going to use this as referential integrity, but since mysql doesn't handle referential integrity (least I can't figure out how to do it if it does) I'm attempting to use php to help me out. This is a small application and more for test purposes than anything else. Ok enough background, here is the question.
User enters information from a page into a text field named "rga".
I want to check that this number ($rga) = an RTA number in the main table BEFORE inserting the rest of the information from the page. If there is not an RTA number that equals $rga then I want it to die.
I have this in my page...
$res = mysql_query("SELECT RTA FROM maindcp WHERE RTA = '$rga'"
or die("RTA doesn't exist"
It continues the process regardless if the RMA does or doesn't exist. It either returns a value or returns an empty set, and if i'm correct, an empty set is still "true" so it continues on with the rest of the script.
I then put this after the query but it still continues on-- i don't know if this is even remotely close to what it should be:
$res = mysql_query("SELECT RTA FROM maindcp WHERE RTA = '$rga'"
or die("RTA doesn't exist"
if ($res = $rga) {
} else {print "rta doesn't exist";}
and again it just continues on thru the script and doesn't even blink.
What I want is for it to stop if the number in $rga is not in the maindcp table's RTA column. How could I accomplish this? thanx!
Nico