Setting up a search
Posted: Mon Aug 07, 2006 5:06 pm
I want to set up a search criteria.
What I have is one table. One of the fields is named number. In it are numbers ranging from 1 to 66.
I would like to create a search form that will allow a visitor to select which section of the database to search. Here are the options:
all - number 1 - 66 (select * FROM table WHERE text LIKE '%$keyword%')
old - number 1- 39 (select * FROM table WHERE number <40 AND text LIKE '%$keyword%')
new - number 40 - 66 (select * FROM table WHERE number >39 AND text LIKE '%$keyword%')
What I have so far is this:
How would I set the variables from the radio inputs to get me the first part of the WHERE clause?
Thanks
David P.
What I have is one table. One of the fields is named number. In it are numbers ranging from 1 to 66.
I would like to create a search form that will allow a visitor to select which section of the database to search. Here are the options:
all - number 1 - 66 (select * FROM table WHERE text LIKE '%$keyword%')
old - number 1- 39 (select * FROM table WHERE number <40 AND text LIKE '%$keyword%')
new - number 40 - 66 (select * FROM table WHERE number >39 AND text LIKE '%$keyword%')
What I have so far is this:
Code: Select all
<form name="form" action="search.php" method="get">
Search:
<input type="radio" name="pull" value="all"> All
<input type="radio" name="pull" value="old"> Old
<input type="radio" name="pull" value="new"> New
<br />
<br />
Keyword: <input type="text" name="q" />
<input type="submit" name="Submit" value="Search" />
</form>
<?php
// Get the search variable from URL
$var = @$_GET['q'] ;
$keyword = trim($var); //trim whitespace from the stored variableHow would I set the variables from the radio inputs to get me the first part of the WHERE clause?
Thanks
David P.