Search page

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

 



K, first off I'm brand new to PHP and databases.  So I
hope my question isn't stupid or unfitting to the
list.  
I am creating a "search and results" page of, right
now 3 fields with more to add. 
Perhaps not necessary to my question, I have created a
working SQL statement which involved one main
transactional table and a number of joins to "static"
tables where the id codes inserted into the main table
are referenced.  All is fine.  
I thought I could use AND / OR statements, but both
don't allow for any number of fields unusued or force
a return if the first condition is met.  I have a
variable in the SQL statment , like LocationCity =
'resset1', LocationState = 'resset2', etc.

Just sure how to get the code to see if it was passed
a value or not.  Also to treat each field
independently, so if the user leaves the first 2
unchanged , and only enters the 3rd it will search for
that particular condition.  

Also I should mention, that when the Search form comes
up, all the drop down menus say "Please Select", that
label actually has a value, which I assume is common. 
Regardless on "submit" that value is going.   

I was looking at the following code but the !='' tells
me that it's looking for an empty string.  So if my
dead "Please Select" value is sent , do I need to put
the value in there, i.e. !='XXX' ?

<?php
if (isset($HTTP_GET_VARS['states']) &&
$HTTP_GET_VARS['states']!=''){
  if (!isset($isNotFirst) OR $isNotFirst==false){
       $isNotfirst = true;
       $KT_search = '1=1 AND ';
  }else{
       $KT_search .=' AND ';
  }
  $KT_search .='LocationState =
\''.$HTTP_GET_VARS['states'].'\' ';
}
?>

Well I hope I don't get flamed since I'm obviously
clueless and seeking some advice when perhaps I should
be finding it on my own. 

Thank you ,
Stuart

-- 
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