|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
thiebo Smarty Pro
Joined: 16 Jan 2005 Posts: 144 Location: Paris
|
Posted: Thu Feb 03, 2005 8:37 pm Post subject: SmartyPaginate remembering mysql_query |
|
|
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 :
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...
Thiebo |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Feb 03, 2005 8:52 pm Post subject: Re: SmartyPaginate remembering mysql_query |
|
|
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 |
|
thiebo Smarty Pro
Joined: 16 Jan 2005 Posts: 144 Location: Paris
|
Posted: Thu Feb 03, 2005 9:09 pm Post subject: |
|
|
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 :
and mysteriously I get those error messages only when I go to the second page (results 7 to 14)... |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Feb 03, 2005 9:16 pm Post subject: |
|
|
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 |
|
|
|
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
|