moondance
09-05-2003, 06:41 AM
I have on my page a select box:
echo "<select name = SearchType>
<option value = Keyword>Search by Keyword</option>
<option>-----</option>
<option value = In Progress>Status: In Progress</option>
<option value = Awaiting Information>Status: Awaiting Information</option>
<option value = Complete>Complete</option>
</select>";
and a text box to search for a keyword:
<input type = text name = SearchTerm>
$SearchTerm = $_POST['SearchTerm'];
$SearchType = $_POST['SearchType'];
Then the retreival:
if ($SearchType =="Keyword")
{
$result = mysql_query("select * from accounts where description like '$SearchTerm' ") or die ("Can't connect");
}
else
{
$result = mysql_query("select * from accounts where status = '$SearchType' ") or die ("Can't connect");
}
This acts as a simple search, where a user can search for records based on their status, complete, in progress or awaiting information.
Searching via keyword works fine, and so does searching for records with a status of complete. Yet searching with the other status' doesn't work. When i echoed $SearchType, it only stores the first word - thats why completed works (cos its one word) whereas awaiting information is echoed as 'awaiting', and in progress is echoed as 'in'.
Any ideas how to solve this?
echo "<select name = SearchType>
<option value = Keyword>Search by Keyword</option>
<option>-----</option>
<option value = In Progress>Status: In Progress</option>
<option value = Awaiting Information>Status: Awaiting Information</option>
<option value = Complete>Complete</option>
</select>";
and a text box to search for a keyword:
<input type = text name = SearchTerm>
$SearchTerm = $_POST['SearchTerm'];
$SearchType = $_POST['SearchType'];
Then the retreival:
if ($SearchType =="Keyword")
{
$result = mysql_query("select * from accounts where description like '$SearchTerm' ") or die ("Can't connect");
}
else
{
$result = mysql_query("select * from accounts where status = '$SearchType' ") or die ("Can't connect");
}
This acts as a simple search, where a user can search for records based on their status, complete, in progress or awaiting information.
Searching via keyword works fine, and so does searching for records with a status of complete. Yet searching with the other status' doesn't work. When i echoed $SearchType, it only stores the first word - thats why completed works (cos its one word) whereas awaiting information is echoed as 'awaiting', and in progress is echoed as 'in'.
Any ideas how to solve this?