|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Pear paging numrows() probelm
Hello!Can anyone help me with this problematic code!
I use mysql and php ,and the DB_Pager-0.7 It comes as the answer to a form. It shows the correct results in the first page, and the following errors comes up when you want to see the res tof the resulting ages. It warks perfectly if I use fixed values where the $_POST... variables are. Fatal error: Call to undefined function: numrows() in C //helpfull functions <?php function pc_print_link($inactive,$text,$offset='') { if ($inactive) { printf('<font color="#666666">%s</font>',$text); } else { printf('<a href="%s?offset=%d">%s</a>',$_SERVER['PHP_SELF'],$offset,$text); } } function pc_indexed_links($numrows,$offset,$per_page) { $separator = ' | '; // print "<<Prev" link pc_print_link($offset == 1, '<<Prev', $offset - $per_page); // print all groupings except last one for ($start = 1, $end = $per_page; $end < $numrows; $start += $per_page, $end += $per_page) { print $separator; pc_print_link($offset == $start, "$start-$end", $start); } $end = ($numrows > $start) ? "-$numrows" : ''; print $separator; pc_print_link($offset == $start, "$start$end", $start); // print "Next>>" link print $separator; pc_print_link($offset == $start, 'Next>>',$offset + $per_page); } ?> <?php require 'Pager.php'; $dbh = DB::connect('mysql://root:@localhost/db'); $offset = intval($_REQUEST['offset']); $per_page = 2; $numrows = $dbh->getOne('SELECT count(*) AS posa FROM document AS doc_ex,citation, document AS doc_in WHERE citation.external_doc_no=doc_ex.doc_no AND (doc_ex.year between '.$_POST[from_year].' AND '.$_POST[to_year].' ) AND citation.lab_doc_no=doc_in.doc_no AND doc_in.category="'.$_POST[category].'"'); $sth = $dbh->query('SELECT doc_ex.category,doc_ex.title,doc_ex.year FROM document AS doc_ex,citation, document AS doc_in WHERE citation.external_doc_no=doc_ex.doc_no AND (doc_ex.year between '.$_POST['from_year'].' AND '.$_POST['to_year'].' ) AND citation.lab_doc_no=doc_in.doc_no AND doc_in.category="'.$_POST['category'].'" ORDER BY year DESC, category ASC, title ASC'); //$pager= new DB_Pager($sth, $offset, $per_page,$numrows); $pager = new DB_Pager($sth, $offset, $per_page); $data = $pager->build(); //$data = DB_Pager::getData($offset, $per_page,$numrows); echo $data['numrows'] . ' Results found'; // display which records are on this page printf("<br>(Displaying %d - %d of %d)<br>", $data['from'],$data['to'],$data['numrows']); $offset = intval($_REQUEST['offset']); if (! $offset) { $offset = 1; } $per_page = 2; $sql = $dbh->modifyLimitQuery('SELECT doc_ex.category,doc_ex.title,doc_ex.year FROM document AS doc_ex,citation, document AS doc_in WHERE citation.external_doc_no=doc_ex.doc_no AND (doc_ex.year between '.$_POST[from_year].' AND '.$_POST[to_year].' ) AND citation.lab_doc_no=doc_in.doc_no AND doc_in.category="'.$_POST[category].'" ORDER BY year DESC, category ASC, title ASC', $offset - 1,$per_page); // display each row on this page while ($v = $pager->fetchRow()) { print "$v[1]---$v[2]<br>"; } pc_indexed_links($numrows,$offset,$per_page); ?> This is it !Thanks in advance |
|
#2
|
|||
|
|||
|
RE: Pear paging numrows() probelm
Quote:
|
|
#3
|
||||
|
||||
|
RE: Pear paging numrows() probelm
OK - quoting what you wrote the first time didn't help. Try putting your code in php tags and/or highlighting the row you are having problems on. Also is all that code really necessary.
My basic rule of thumb - If I can't figure out what you are trying to ask and where the problem is in under 20 seconds - I move on. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > Pear paging numrows() probelm |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|