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


HTML-Widgets-Search documentation  | view source Contained in the HTML-Widgets-Search distribution.

Index


NAME

Top

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

SYNOPSIS

Top

    <%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>

DESCRIPTION

Top

    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.




METHODS

Top

* html_form_fields : Returns the hidden fields necessary if you want to make a form yourself.

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.

* href : returns a href html tag with the params you send and the params needed to reload the current state of the search

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'
                   }
   );










TODO

Top

    Improve the docs. You can help me !

AUTHOR

Top

Francesc Guasch frankie@etsetb.upc.es

SEE ALSO

Top

perl(1) , DBI.


HTML-Widgets-Search documentation  | view source Contained in the HTML-Widgets-Search distribution.