Page 1 of 1

Query Execution

Posted: Thu Dec 18, 2003 3:35 am
by Arulraj
Hello,

I am getting four input from the user and based on this I am building the query. (Total 16 conditions since 4 input, 2 to the power 4)

I have used "&&" and "||" operator, it was not working, hence I have used "and" and "or" operator. Still I am getting the same answer.

my first five condition goes like this

Code: Select all

if(($RNO=="")  and  ($CNAME=="")  and  ($DOB=="")  and  ($FATHER==""))
	{
	echo "<p align ="center">Select the search criteria correctly.</p>";
	}

	elseif(($RNO!="")  and  (($CNAME=="") or ($DOB=="") or ($FATHER=="")))
	{
	$Query = "SELECT RNO as RegNo,DOB as BirthDate,NAME as ChildName ,F_NAME as FatherName,M_NAME as MotherName  FROM $council WHERE RNO='$RNO'"; 
	}
	elseif(($CNAME!="") and (($RNO=="") or ($DOB=="") or ($FATHER=="")))
	{
	$Query = "SELECT RNO as RegNo,DOB as BirthDate,NAME as ChildName ,F_NAME as FatherName,M_NAME as MotherName  FROM $council WHERE NAME like '%$CNAME%' ORDER BY DOB"; 
	}
	elseif(($DOB!="")  and (($CNAME=="") or ($RNO=="") or ($FATHER=="")))
	{
	$Query = "SELECT RNO as RegNo,DOB as BirthDate,NAME as ChildName ,F_NAME as FatherName,M_NAME as MotherName  FROM $council WHERE DOB='$DOB' ORDER BY RDATE"; 
	}
when i am giving two input or three input it checks for the first part and it executes that part only. it is not coming for the second part (it checks for $RNO!=="" and executes that part even other parameters also satisfies the condition).

Please point out where I am going wrong.

Thanks in advance,
S.Arul

[Edit: Added PHP tags for eyecandy. --JAM]

Posted: Sat Dec 20, 2003 2:36 pm
by Derfel Cadarn
I am not sure where the mistake is exactly, but I know I've been stuck with a similar problem more than once. I get lost in those logical-schemes quite easily.
Have you tried to -simply- draw out the logical schema on a piece of paper? That helped me out a few times, although it probably sounds silly. It helps ME to get a clear view :wink:


====================================
= Yes, I'm trying to get my 100th posting today =
====================================

Posted: Mon Jan 05, 2004 4:03 am
by Arulraj
Hello Derfel

Thanks for your suggestion.

I could solve the problem. I have misused the if statement at the end. that caused all the problem.
Thanks.