![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which field is completed. In ASP I can use: queryA = request.querystring("A") queryB = request.querystring("B") If QueryA <>"" then SQL STATEMENT Elseif QueryB <> then ANOTHER SQL STATEMENT End If The pages checks for a value in QueryA or QueryB then creates the correct SQL Statement.. How do I do this in PHP ?? Thanks | |||
| Advertisements |
| | #2 | ||
| In news:3ef953a4.167992089@news.btclick.com, James @ nothere.com (James) <James @ nothere.com (James)> typed: > Hi, > I have a form with 2 fields. > 'A' > 'B' > > The user completes one of the fields and the form is submitted. > > On the results page I want to run a query, but this will change > subject to which field is completed. > > In ASP I can use: > > queryA = request.querystring("A") > queryB = request.querystring("B") > > If QueryA <>"" then > SQL STATEMENT > > Elseif QueryB <> then > ANOTHER SQL STATEMENT > > End If > > > The pages checks for a value in QueryA or QueryB then creates the > correct SQL Statement.. > > How do I do this in PHP ?? > > Thanks If ($a) { SQL STATEMENT } elseif ($b) { ANOTHER SQL STATEMENT } D. | |||
| | #3 | ||
| In message <3ef953a4.167992089@news.btclick.com>, James <James@nothere.com> writes >Hi, >I have a form with 2 fields. >'A' >'B' > >The user completes one of the fields and the form is submitted. > >On the results page I want to run a query, but this will change >subject to which field is completed. > >In ASP I can use: > >queryA = request.querystring("A") >queryB = request.querystring("B") > >If QueryA <>"" then >SQL STATEMENT > >Elseif QueryB <> then >ANOTHER SQL STATEMENT > >End If > > >The pages checks for a value in QueryA or QueryB then creates the >correct SQL Statement.. > >How do I do this in PHP ?? > >Thanks If(isset($_GET['A']) && $_GET['A'] != "") { // do something as a result of A being set } else if(isset($_GET['B']) && $_GET['B'] != "" ) { // do somethign as a result of B being set } else { // neither set to something other than "" } -- Rob Allen | |||
| | #4 | ||
| "Nikolai Chuvakhin" <nc@iname.com> wrote in message news:32d7a63c.0306250838.3f7583a9@posting.google.c om... > James @ nothere.com (James) wrote in message > news:<3ef953a4.167992089@news.btclick.com>... > > > > > > How do I do this in PHP ?? > > if ($_REQUEST['A']) { > SQL STATEMENT > } else { > if ($_REQUEST['B']) { > ANOTHER SQL STATEMENT > } > } > > Since you are not specifying the method your form uses, I suggested > the use of $_REQUEST array. If you know whether you want to use > GET or POST, you can use $_GET or $_POST array as well. Agreed, I fully recommend using $_REQUEST, etc over global variables. One catch though, this requires PHP 4.1.0 or higher, there are hosting services out there that still run 4.0.x, I know this cos I have clients with this problem. Then this won't work Prior to 4.1.0 there was no equivalent of $_REQUEST, so I guess you could use globals if you must, otherwise use one of $HTTP_POST_VARS for forms, $HTTP_GET_VARS for normal url gets. Note, you can also write the above more compactly as: if ( $_REQUEST['A'] ) { SQL STATEMENT }elseif ( $_REQUEST['B'] ) { ANOTHER SQL } > > Cheers, > NC Thanks, Mark ---------------------------------------------------------------------------- -- Windows, Linux and Internet Development Consultant Email: corporate@scriptsmiths.com Web: http://www.scriptsmiths.com ---------------------------------------------------------------------------- -- | |||
| Featured Websites | ||||
|
![]() |
| Tags: asp, elseif, php, select, sql, yes |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| width of select tag | huzefa | HTML | 1 | 07-01-2007 1:57 PM |
| Help with a select query | Beetlegeuse | Database | 0 | 06-10-2007 12:19 AM |
| Why does 'SELECT * FROM countries' truncate characters and SELECT country FROM countries does not ? | PRS | Database | 0 | 05-31-2007 8:48 PM |
| select two conditions of a many to one | Dont Wantogetspammed | Database | 1 | 05-31-2007 8:44 PM |
| Select while in | Bill Y. Barool | Database | 2 | 05-31-2007 8:39 PM |
| Featured Websites | ||||
|