1 |
dpavlin |
1.1 |
#!/usr/bin/perl -w |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use CGI qw/:standard -no_xhtml/; |
5 |
|
|
use DBI; |
6 |
|
|
use Text::Query; |
7 |
|
|
|
8 |
|
|
my $url="http://www.nn.hr/CijeliBrojS.asp?god=%d&br=%d#%d"; |
9 |
|
|
|
10 |
|
|
my %labels = ('Simple'=>'jednostavnim', 'Advanced'=>'naprednim'); |
11 |
|
|
|
12 |
|
|
print header(-charset=>'iso-8859-2'),start_html(-title=>'NN pretrazivanje',-lang=>'hr'),start_form; |
13 |
|
|
print "Tra¾i zakon: ",textfield('search')," sa "; |
14 |
|
|
print popup_menu(-name=>'type',-values=>[ keys %labels ],-labels=>\%labels); |
15 |
|
|
print submit(-value=>'pretra¾ivanjem'); |
16 |
|
|
print end_form,hr; |
17 |
|
|
|
18 |
|
|
if (param('search') && param('type')) { |
19 |
|
|
my $question; |
20 |
|
|
my ($query) = Text::Query->new('blurk', # param('search'), |
21 |
|
|
-parse => 'Text::Query::Parse'.param('type') || 'Advanced', |
22 |
|
|
-build => 'Text::Query::BuildSQLPg', |
23 |
|
|
-fields_searched => 'title_czs', |
24 |
|
|
-select => 'select br,god,aname,nr,title from nn where __WHERE__ order by god desc,br desc,nr asc' |
25 |
|
|
); |
26 |
|
|
|
27 |
|
|
$query->prepare(param('search')); |
28 |
|
|
|
29 |
|
|
# print "--",$query->matchstring(); |
30 |
|
|
|
31 |
|
|
my $dbh = DBI->connect("DBI:Pg:dbname=nn","dpavlin","") || die $DBI::errstr; |
32 |
|
|
my $sth=$dbh->prepare($query->matchstring()) || die $dbh->errstr(); |
33 |
|
|
$sth->execute() || die $dbh->errstr(); |
34 |
|
|
while (my $row = $sth->fetchrow_hashref()) { |
35 |
|
|
print br,"<tt><a href=\"",sprintf($url,$row->{god},$row->{br},$row->{aname}),"\">NN",$row->{god},"/",$row->{br},"</a> ",$row->{nr},"</tt> ",$row->{title},"\n"; |
36 |
|
|
} |
37 |
|
|
} |
38 |
|
|
|