Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

SmartyPaginate remembering mysql_query

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
thiebo
Smarty Pro


Joined: 16 Jan 2005
Posts: 144
Location: Paris

PostPosted: Thu Feb 03, 2005 8:37 pm    Post subject: SmartyPaginate remembering mysql_query Reply with quote

Hi again.

As I said earlier tonight, the pagination works really neat.

However... I still echo my_query just to see the results, and it's funny, because on the first page with results, the query is exactly what I entered with the form, e.g. :


Quote:
SELECT * FROM Actes, Bibliographie
WHERE Bibliographie.id = idBiblio
AND Contrat LIKE '%vent%' LIMIT 0, 7


And I get to see the results. But when I click on the next 7 results I get :

Quote:
SELECT * FROM Actes, Bibliographie
WHERE Bibliographie.id = idBiblio
AND Contrat LIKE '%%' LIMIT 14, 7


In other words, the parameter that I entered for the mysql_query which is to get the rows where contrat LIKE '%vent%', is not transmitted to the next page of results which shows me the results with Contrat LIKE '%%' and then shows me a table which is just fine.

No error messages on the first list of results but for the second list of results :

Quote:
[Thu Feb 03 21:28:39 2005] [error] [client 127.0.0.1] File does not exist: /var/www/html/var, referer: http://localhost/smartysite/becherche.php?next=8
[client 127.0.0.1] PHP Notice: Undefined index: contrat in /var/www/html/smartysite/fonctions.php on line 63, referer: http://localhost/smartysite/becherche.php


fonctions.php =

[php:1:a799fd0fb5]<?php
function get_db_results()
{
$motcle = $_POST['motcle'];
$nom_auteur = $_POST['nom_auteur'];
$contrat = $_POST['contrat'];

$connexion = mysql_pconnect(SERVEUR, NOM, PASSE) or die(mysql_error());
mysql_select_db (BASE, $connexion) or die(mysql_error());


$requete = "SELECT * FROM Actes, Bibliographie
WHERE Bibliographie.id = idBiblio
AND MotsClef LIKE '%$motcle%'
AND Nom_Auteur LIKE '%$nom_auteur%'
AND Contrat LIKE '%$contrat%'
LIMIT ". SmartyPaginate::getCurrentIndex() . ", ". SmartyPaginate::getLimit();
echo $requete ;
$_data = sql_query($requete) or die(mysql_error());
SmartyPaginate::setTotal(50);

return $_data;
}
?>[/php:1:a799fd0fb5]

I never thought one could ask so many questions on only one subject...
Embarassed

Thiebo
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Feb 03, 2005 8:52 pm    Post subject: Re: SmartyPaginate remembering mysql_query Reply with quote

thiebo wrote:

And I get to see the results. But when I click on the next 7 results I get :

Quote:
SELECT * FROM Actes, Bibliographie
WHERE Bibliographie.id = idBiblio
AND Contrat LIKE '%%' LIMIT 14, 7



The next result set should be LIMIT 7,7, not LIMIT 14,7. Your are missing a result set link somehow. You should have setLimit() set to 7 and setTotal() set to the total number of records.
Back to top
View user's profile Send private message Visit poster's website
thiebo
Smarty Pro


Joined: 16 Jan 2005
Posts: 144
Location: Paris

PostPosted: Thu Feb 03, 2005 9:09 pm    Post subject: Reply with quote

Yes, you're right, the second query is :



Quote:
SELECT * FROM Actes, Bibliographie
WHERE Bibliographie.id = idBiblio AND
Contrat LIKE '%%' LIMIT 7, 7


setLimit is set to 7 and setTotal is set to 50 and that corresponds to what I get in the webbrowser.

Do you have any idea of why the result set link is missing ?

This is the error message :

Quote:
[client 127.0.0.1] PHP Notice: Undefined index: contrat in /var/www/html/smartysite/fonctions.php on line 63, referer: http://localhost/smartysite/becherche.php
[Thu Feb 03 22:04:25 2005] [error] [client 127.0.0.1] File does not exist: /var/www/html/var, referer: http://localhost/smartysite/becherche.php?next=8


and mysteriously I get those error messages only when I go to the second page (results 7 to 14)...
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Feb 03, 2005 9:16 pm    Post subject: Reply with quote

My guess is when you click the "next" links in the pagination, you lose your $_POST data from the original form submission. You need to retain that information in a $_SESSION var or something similar so you can continue the queries from page to page when you paginate.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP