Actually, %fdat doesn't seem to be printable. After calling :
*set = DBIx::Recordset->Search({%fdat,('!DataSource' => $db,
'!Table' => $table,
'$fields' => $joined_col,
'$where' => $query,
'$max' => 5)});
and testing:
if(undef %fdat) {
print "<b>%fdat undef</b>",br;
} else {
print "<b>%fdat def</b>",br;
while (($a,$b) = each %fdat) {
print "$a => $b";
}}
it says '%fdat undef' but won't print out each %fdat. Trying 'if
(exists($fdat{'$next'})), or any other key from Search above,
gives also a negative result.
I believe %fdat keeps the old parameters (q_col,columns,q_comp) instead of
getting and passing the new 'Search' ones above. Below is the 'Next' rendering
HTML code that points to that.
*****
<form method="POST"><input type="hidden" name="$start" value="0">
<input type="hidden" name="$max" value="5">
<input type="submit" name="$next" value="Next"> </form><input type="hidden"
name=".cgifields" value="q_col" /><input type="hidden" name=".cgifields"
value="columns" /><input type="hidden" name=".cgifields" value="q_comp"
/></form></body></html>
*****
How do I get the right %fdat parameters, so that PrevNext Form works? Now only
the first same 5 search results come up (there are many more).
As you can see in my code below the %fdat parameters passed are the ones
generated before my first 'submit'. I have many submits after that.
Further below is the Debug output.
Marcus
*************************
#!/usr/bin/perl -w
$|++;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use DBI;
use DBIx::Recordset;
###Connects to db
$db = DBIx::Database -> new({'!DataSource' => 'dbi:Pg:dbname=marcus_test',
'!Username' => 'nobody',
'!KeepOpen' => 1}) or die "Couldn't connect to
database";
print header(),
start_html(-title=>'AG Database Access - Query page',
-BGCOLOR=>'white');
print start_form(),
h1("AG Database Access"),hr;
###Choose tables
$tables = $db->AllTables;
print br,b("Select table:"),br,
popup_menu(-name =>'tables',
-values =>[sort keys(%$tables)]),
submit(-name =>'ok',
-value =>'Ok'),br;
$table = param('tables');
if (param('tables')) {
$columns = $db->AllNames($table);
print b("Select columns to display:"),
checkbox_group(-name =>'columns',
-values=>[@$columns],
-rows =>4),br;
$joined_col = join(",",param('columns'));
###Specify query
print b("Specify query:"),br,
scrolling_list(-name =>'q_col',
-values=>[@$columns],
-size =>1),
scrolling_list(-name =>'q_comp',
-values=>["equals","less than or equal","less than"],
-size=>1),
textfield(-name=>'q_string',
-size=>15),br,
"Alternative SQL query: ",
textfield(-name=>'sql_string',
-size=>42),hr;
$one=param('q_col');
$two=param('q_comp');
$three=param('q_string');
if ($two eq "equals") {
$query = "$one=$three"; }
elsif ($two eq "less than or equal") {
$query = "$one<=$three"; }
elsif ($two eq "less than") {
$query = "$one<$three"; }
if (param("sql_string")) {
$query = param("sql_string");
}
print submit(-name =>'submit',
-value =>'Submit Query'),
defaults('Reset'),br;
} # if param($tables)
if (param('submit') || param('$next')) {
$DBIx::Recordset::Debug = 2;
*set = DBIx::Recordset->Search({%fdat,('!DataSource' => $db,
'!Table' => $table,
'$fields' => $joined_col,
'$where' => $query,
'$max' => 5)});
if(undef %fdat) {
print "<b>%fdat undef</b>",br;
} else {
print "<b>%fdat def</b>",br;
while (($a,$b) = each %fdat) {
print "$a => $b";
}
}
$DBIx::Recordset::FetchsizeWarn=0;
###Print table and table head
print "<TABLE BORDER=4 WIDTH=60% BGCOLOR=\"#EEEAAA\"
BORDERCOLORLIGHT=\"#AAAAAA\">";
print Tr({-align=>'CENTER'},td[keys(%set)]);
foreach $row (@set) {
print Tr({-align=>'CENTER'},td[values(%$row)]);
}
print "</TABLE>";
###Should print out workable next,prev buttons
print $set -> PrevNextForm ("Previous", "Next", \%fdat);
} #if(param('submit') || param('$next')) {
print end_form;
print end_html;
exit;
******************
DB: Use already open dbh for dbi:Pg:dbname=marcus_test (id=1, numOpen = 0) DB:
'SELECT id,sbjrank,sbjname FROM mc_bplite_nt_go WHERE score=15 LIMIT 6'
bind_values=<> bind_types=<>
[Here is Table]
[Next button]
DB: Disconnect (id=1, numOpen = 0)
**********************
> > I have a little problem with PrevNextForm in DBIx::Recordset.
> > When I run the code below the table is displayed as I want with the
> > number of rows I specified in $max. But when I press 'Next' the SAME
> > page
> > comes up. It's impossible to see further than the $max rows.
> > I also attach the some of the HTML output.
> > Marcus
>
> The codes looks ok to me, at least when %fdat is correctly filled with the
> parameters passed to the script and the resulting recordset contains more
> then 5 rows.
>
> Print out %dat, and make sure you see $next in it, when you have pressed the
> next button. Maybe set $max to 10 and see if you really have more the 5
> records in your result set
>
> Gerald
>
> -------------------------------------------------------------
> Gerald Richter ecos electronic communication services gmbh
> Internetconnect * Webserver/-design/-datenbanken * Consulting
>
> Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
> E-Mail: [EMAIL PROTECTED] Voice: +49 6133 925131
> WWW: http://www.ecos.de Fax: +49 6133 925152
> -------------------------------------------------------------