RE: Question on the use of where statements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



so...best to build the statement dynamically and execute it once only if the input box has a value in it...

$sql = "select * from table where 1 ";

if (isset($_POST['field1'])){ $sql .= " and column1 = '".$_POST['field1']. "'";
...
if (isset($_POST['fieldN'])){ $sql .= " and columnN = '".$_POST['fieldN']. "'";


$result = mysql_query($sql);
...

bastien

From: Stuart Felenstein <stuart4m@xxxxxxxxx>
To: php-db@xxxxxxxxxxxxx
Subject:  Question on the use of where statements
Date: Wed, 1 Dec 2004 07:28:24 -0800 (PST)

I posted this over on mysql list. Not trying to be
redundant, but would like to get some feedback.

Basically I'm wondering.
I am creating a search form , dynamic query, that
could potentially have in the area of 40+ where
statements.

i.3.   1- where x = y and

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux