Jump to content

syntax error maybe?


Recommended Posts

Hi. ok ive been working for about 2 hours on 2 lines that for some reason doesnt work. 

i have a form with 2 inputs: order# and phone#. 

when user press submit i want it to search the DB. if he entered both phone# and order# the query will be other than if he entered only one of them. 

so actually  i have 4 cases. 1: user submitted without phone# and without order#

2: user submitted with phone# but without order#

3: user submitted without phone# but with order#

4: user submitted with both.

can someone help me with the syntax? ive been working on it for freaking hours and it doesnt seem to work. 

Edited by Weiss
Link to post
Share on other sites
if (isset($_GET['submit'])){
$flag =1;//1 means both phone# and order# are entered

    if (!isset($_GET['order_num'])) 
	    { if (!isset($_GET['phonesrch'])) 
		             {$flag=2;} //means order# isnt set and phonesrch isnt set
				else{ $flag=3; }//means order# isnt set but phone# is set
        }
		else {if (!isset($_GET['phonesrch'])) {flag=4;} //means order# is set, phone# isnt
		     }

this is my code but somewhere i guess theres a syntax error

Link to post
Share on other sites

Yes thank you, realised that just now. do you think there's a better way to attack this other than all this nested if's ?

 

btw, if isset returns true all the time do i still need it? or can i just use the !empty?

Edited by Weiss
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...