PEAR Packages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPEAR Packages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old July 12th, 2005, 05:14 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
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 Crogram FilesApache GroupApache2htdocsPager.php on line 94


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

Reply With Quote
  #2  
Old September 8th, 2005, 04:50 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: Pear paging numrows() probelm


Quote:
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 Crogram FilesApache GroupApache2htdocsPager.php on line 94


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


Reply With Quote
  #3  
Old September 9th, 2005, 12:17 AM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,753 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 8 h 15 m 54 sec
Reputation Power: 7
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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPEAR Packages > Pear paging numrows() probelm


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek