creating a SELECT AND query

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

 



I have a textboxt which searches for the surname of a client. A SELECTBOX 
searches for the area. I am trying to generate a query that searches all of 
scotland (when area=a) and by area (say I live in area 16= "edinburgh") and 
combine this with the name search



select name="area" class="text" id="area">
            <option value="a">All of Scotland</option>
            <option value='1'>Aberdeen City Counci...</option>
         <option value='16'>Edinburgh City Counc...</option>
 <option value='17'>Falkirk Council</option>
   <option value='18'>Fife Council</option>
   <option value='19'>Glasgow City Council</option>
 <option value='20'>Highland Council</option>
 <option value='21'>Inverclyde Council</option>
<option value='22'>Midlothian Council</option>
                              <option value='23'>Moray Council</option>
                               </select>


This is what I thought would work..


$query1= "select * from $table_name WHERE sname LIKE '$search_string%' ";

if ($area="a")  {
$query1 .=" AND area='a'";
 }
 else {
  $query1 .="AND area='$area'";
  } 

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux