LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   PHP paging problem (https://www.linuxquestions.org/questions/linux-newbie-8/php-paging-problem-294090/)

jojojo 02-23-2005 07:25 PM

PHP paging problem
 
How do you pass a search string in paging???

Hello, my name is johan. Right now i am developing a
system using PHP
and MySQL. I have a paging problem. The paging works
when i want to
display all the person from all countries BUT it
does'nt work when i
search for a particular person from a certain
countries. My problem
is when i search for a participant from country
Canada, the first
page will display correctly all the person from
country Canada ONLY
in Page2. But when i click on the link "Previous",
"Next", "Page2,
Page3......", it will display all the person from
all countries. Is
it because i did not carry the variable of what i search for to
other pages? Do you
know what is causing the problems?

Eg. I have 2 pages.

Page1 is the search form
Page2 is display the paging of my search results.


Does anybody have a sample code on how to pass a search variable in the link to different pages????

This is my query:

$query = "SELECT * FROM person, tablecountry, tablecourse, course WHERE Name LIKE '$name1%' AND FamilyName LIKE '$name2%' AND Year attended LIKE '$tahun%' AND Country LIKE '$country%'"
. " AND person.KodCountry=tablecountry.KodCountry AND person.IDPerson=course.IDPerson AND course.KodCourse=tablecourse.KodCourse order by Name ";
$result = mysql_query($query);

echo "<a href=\"searchperson.php? WHAT SHOULD I INSERT HERE?????">Page$i</a>";

david_ross 02-24-2005 12:13 PM

If you use "searchperson.php?page=2&perpage=10" you can then add a LIMIT clause to the sql statement and use the given values. You could hardset "perpage" but it is nice to give people some choice when viewing lists like this.


All times are GMT -5. The time now is 03:12 PM.