| View previous topic :: View next topic |
| Author |
Message |
mreznisistem
Joined: 04 Jan 2008 Posts: 12 Location: Serbia
|
Posted: Thu Apr 03, 2008 2:20 pm Post subject: pager setOptions problem |
|
|
I have tried to use the following code:
require_once('Pager.php')
$pager = & Pager::factory($pager_options);
$pager->setOptions($pager_options);
$pager = Pager::build();
It simply does not work. setOptions is not recognised as a method of the class pager. I could not find anything on the web such as an example or code.
Any idea? |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
|
| Back to top |
|
 |
mreznisistem
Joined: 04 Jan 2008 Posts: 12 Location: Serbia
|
Posted: Thu Apr 03, 2008 6:13 pm Post subject: $pager->getDebugInfo()); |
|
|
I have done what you recommend:
$pager_options = array(
'mode' => 'Jumping',
'perPage' => 8,
'delta' => 5,
'totalItems' => $broj_zaposlenih
);
$pager->setOptions($pager_options);
if (PEAR::isError($pager)) {
die($pager->getMessage . ', ' . $pager->getDebugInfo());
}
still the message is:
Fatal error: Call to a member function setOptions() on a non-object in C:\wamp\www\novi\selzaposlenebak.php on line 121
I do not have any debug info neither anything from message. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Thu Apr 03, 2008 6:15 pm Post subject: |
|
|
| PHP already dies before the debug code. You'll have to insert the code directly after the factory() call. |
|
| Back to top |
|
 |
mreznisistem
Joined: 04 Jan 2008 Posts: 12 Location: Serbia
|
Posted: Thu Apr 03, 2008 6:19 pm Post subject: |
|
|
Sorry I did put this one:
if (PEAR::isError($pager)) {
die($pager->getMessage() . ', ' . $pager->getDebugInfo());
}
and the message is the same |
|
| Back to top |
|
 |
mreznisistem
Joined: 04 Jan 2008 Posts: 12 Location: Serbia
|
Posted: Thu Apr 03, 2008 6:29 pm Post subject: |
|
|
It still the same, but I am having my pager output apart from old message
if (isset($_POST['q']))
{
// Get the search variable from URL
$pretraga = 1;
$trimmed = $_POST['q'];
$text_slanje = trim($_POST['txthid']); //trim whitespace from the stored variable
$broj_zaposlenih = $mdb2->queryOne("SELECT COUNT(*) FROM zaposleni WHERE firstname LIKE \"%$trimmed%\" OR
lastname LIKE \"%$trimmed%\"");
$pager_options = array(
'mode' => 'Jumping',
'perPage' => 10,
'delta' => 5,
'totalItems' => $broj_zaposlenih
);
$pager->setOptions($pager_options);
if (PEAR::isError($pager)) {
die($pager->getMessage() . ', ' . $pager->getDebugInfo());
}
$pager->build();
echo "<br>";
}
elseif (isset($_GET['txtid']))
{
// videti koliko zapisa imamo u tabeli zaposlenih
//prva strana ako nema pretrage vec listanje
echo "HEREIAM";
$pretraga = 0;
$text_slanje = trim($_GET['txtid']);
$broj_zaposlenih = $mdb2->queryOne('SELECT COUNT(*) FROM zaposleni');
$pager_options = array(
'mode' => 'Jumping',
'perPage' => 8,
'delta' => 5,
'totalItems' => $broj_zaposlenih
);
$pager = & Pager::factory($pager_options);
if (PEAR::isError($pager)) {
die($pager->getMessage() . ', ' . $pager->getDebugInfo());
}
echo "<br>";
}
The system is simple but still it is not working because of something fundamental what I am missing. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Thu Apr 03, 2008 6:40 pm Post subject: |
|
|
Which of the two cases of your script will be evaluated? The $_POST or the $_GET part? In the $_POST part, the order is still wrong.
Adding | Code: | | error_reporing(E_ALL); | might also help.
And please use the {code} environment (with square brackets) to make your code readable next time. |
|
| Back to top |
|
 |
mreznisistem
Joined: 04 Jan 2008 Posts: 12 Location: Serbia
|
Posted: Thu Apr 03, 2008 7:02 pm Post subject: |
|
|
if (isset($_GET['txtid']))
{
$pretraga = 0;
$text_slanje = trim($_GET['txtid']);
$broj_zaposlenih = $mdb2->queryOne('SELECT COUNT(*) FROM zaposleni');
$pager_options = array(
'mode' => 'Jumping',
'perPage' => 8,
'delta' => 5,
'totalItems' => $broj_zaposlenih
);
$pager = & Pager::factory($pager_options);
if (PEAR::isError($pager)) {
die($pager->getMessage() . ', ' . $pager->getDebugInfo());
}
}
elseif (isset($_POST['q']))
{
// Get the search variable from URL
$trimmed = $_POST['q'];
$text_slanje = trim($_POST['txthid']); //trim whitespace from the stored variable
$broj_zaposlenih = $mdb2->queryOne("SELECT COUNT(*) FROM zaposleni WHERE firstname LIKE \"%$trimmed%\" OR
lastname LIKE \"%$trimmed%\"");
$pager_options = array(
'mode' => 'Jumping',
'perPage' => 10,
'delta' => 5,
'totalItems' => $broj_zaposlenih
);
$pager->setOptions($pager_options);
if (PEAR::isError($pager)) {
die($pager->getMessage() . ', ' . $pager->getDebugInfo());
}
$pager->build();
}
The idea is that I going to have list of all records, than I will supply a sort of search form on the same page if the list is too big to be listed and paged. Search might be the solution to locate a certain record quickly. GET as it is is not important. What is important is how to change from list towards SEARCH. Why the order in the POST part is wrong?
What do you mean by the code environment with square brackets?
With error_reporting I have got a bit more info:"
Notice: Undefined variable: pager in C:\wamp\www\novi\selzaposlenebak.php on line 122
Fatal error: Call to a member function setOptions() on a non-object in C:\wamp\www\novi\selzaposlenebak.php on line 122"
It seems to me that I did not initiated pager which is wrong. Before I post I get pager, than I posted SEarch and pager is not initiated and that might be the problem? |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Thu Apr 03, 2008 7:10 pm Post subject: |
|
|
In the elseif case there is no factory() call anymore now, and $pager can't be defined ...
Again, please make your code readable ... |
|
| Back to top |
|
 |
mreznisistem
Joined: 04 Jan 2008 Posts: 12 Location: Serbia
|
Posted: Thu Apr 03, 2008 7:23 pm Post subject: |
|
|
That was the problem.
Cqan you tell me how to environement {code}. I am having problem with indent evidently. When I put from php Coder, there is indent, but when I post with submit I loose all indentation.
Thank you. My problem was that I did not initialise $pager. Very stupid of me. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Thu Apr 03, 2008 8:34 pm Post subject: |
|
|
Just like in HTML, you could surround your code with tags here in the forum.
The syntax is:
[code]
... your PHP code ...
[/code]
You can also use the buttons above the textarea field to open and close the "code environment". |
|
| Back to top |
|
 |
|