
HTML::Widgets::Search - Perl module for building searches returning HTML

<%perl>
use HTML::Widgets::Search;
my $search=HTML::Widgets::Search->new(
query => "SELECT idCustomer,name ".
" FROM customers WHERE name LIKE 'a%' ".
" ORDER BY name ",
field_id => "idCustomer",
limit => 10,
form_fields => \%ARGS,
dbh => $dbh
);
</%perl>
<% $search->n_found %> customers found
<% $search->current_start %> to <% $search -> current_end %><BR>
<% $search->head %>
<TABLE WIDTH="90%">
<%perl>
$search->render_table(
link=>"http://www.me.com/show_customer.html"
);
</%perl>
</TABLE>
<A HREF="search_customer.html<% $search->next %>">next</A>
<A HREF="search_customer.html<% $search->prev %>">previous</A>
<% $search->prev(submit => '<INPUT TYPE="IMAGE"
SRC="/img/prev.gif"
NAME="previous" BORDER=0>')
%>
%#################################################################3
<TABLE>
% while (my @row=$search->fetchrow) {
<TR><TD>
<% join "</TD><TD>", @row %>
</TD></TR>
% }
</TABLE>

The programmer designs a html form with some field values, then
you can write a sql query using those fields.
The constuctor requires a SQL statement and a valid DBI object.
render_table returns a HTML table with the results , if a link
is provided every field of the table has that link. If a field_id
is provided the link adds that field as a parameter. This field
must be the first field of the select query and is discarded in
the render.
Supports native mysql limit clauses. For other DBs skips untill start
and fetches until limit.
Give it a try, the synopsis may help you start.
Let me know if it's useful for or whatever you want to tell me.

Example:
<form method="post">
<input type="submit">
<% $search -> html_form_fields %>
</form>
If you don't add the html_form_fields method the search will the reset to the very first position. Doing it like the example the search current position will be kept. I don't know how to explain better, please gimme a hint.
Example:
$search->href( name1 => 'value1' , name2 => 'value2' )
returns:
<a href="current_page.html?name1=value1&...I<current state params>">
So the current page will be reloaded with some new values in some arguments.
If you don't want to call the current page you must call it this way:
$search-> href( url => 'http://another_site/cgi-bin/file.cgi', args => { name1 => 'value1', name2 => 'value2' } );

Improve the docs. You can help me !

Francesc Guasch frankie@etsetb.upc.es

perl(1) , DBI.