Hello,
I would like to offer the possibility of searching in different fields from a Chronoconnectivity table.
I use now a script found in another Post, to do the search. This code goes in the Where section:
With this code I have to put a single box for every field to search into, in the Head section. Since there are many fields in the table, I woulk like not to offer a lot of boxes for the resarch (one for every field) but better give the chance to the user to choose the fields to search in, and put the text near the name of the field.
Something like this:
Now, I don't know how to get the value of the chosen field (field1...) to do the search on it according to the text introduced (searchfield1...).
Any idea, any code?
Thanks in advance,
Gonzalo
I would like to offer the possibility of searching in different fields from a Chronoconnectivity table.
I use now a script found in another Post, to do the search. This code goes in the Where section:
<?php
$search_array = array('firstname');
$where = array();
foreach ( $search_array as $search ) {
$value = JRequest::getVar($search, '' , 'post');
if ( $value ) {
$where[] = " $search LIKE '$value%' ";
}
}
if ( !empty($where) ) {
echo " WHERE ".implode(' AND ', $where);
}?>
With this code I have to put a single box for every field to search into, in the Head section. Since there are many fields in the table, I woulk like not to offer a lot of boxes for the resarch (one for every field) but better give the chance to the user to choose the fields to search in, and put the text near the name of the field.
Something like this:
<form action="search" method="POST">
<select name="field1"><option value="">Choose a field</option>
<option value="journal">Journal</option>
<option value="title">Title</option>
<option value="author">Author</option>
<option value="text">text</option></select>
<input type="Text" name="searchfield1">
<br>
<select name="field2"><option value="">Choose a field</option>
<option value="journal">Journal</option>
<option value="title">Title</option>
<option value="author">Author</option>
<option value="text">text</option></select>
<input type="Text" name="searchfield2">
<br>
<select name="field3"><option value="">Choose a field</option>
<option value="journal">Journal</option>
<option value="title">Title</option>
<option value="author">Author</option>
<option value="text">text</option></select>
<input type="Text" name="searchfield3">
</form>
Now, I don't know how to get the value of the chosen field (field1...) to do the search on it according to the text introduced (searchfield1...).
Any idea, any code?
Thanks in advance,
Gonzalo