|
|||||||
| PHP Discussion and technical support for using and deploying PHP based websites. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Help with pagination on site search script
Hi here,
I'm trying to implement a site search script written in PHP. I'm not advanced in PHP but the script is simple and query the DB and show results without a problem. However, there is no way I can get the pagination (previews/next buttoms at the bottom of the results to work. Any ideas? The site is running locally. Thanks in advance dkid here is the code PHP Code:
__________________
fdkid Last edited by f_dkid; 05-27-2007 at 07:07 PM. Reason: php code |
|
#2
|
||||
|
||||
|
I quickly rewrote what you hade, It may work let me know of the bugs
PHP Code:
__________________
Auckland, New Zealand, Web Design & Hosting. - Inbox Design Sheldon Lendrum, Technology, PHP, Mootools & More... Simple Site a Completely Dynamic site using text files, PHP and no mySQL. |
|
#3
|
||||
|
||||
|
Quote:
Code:
# query one
select
count(*)
from tablename
where contact_first != ''
or contact_first like '%{$item}%'
or contact_last like '%{$item}%'
or contact_category like '%{$item}%'
Code:
# query two
select
*
from tablename
where contact_first != ''
or contact_first like '%{$item}%'
or contact_last like '%{$item}%'
or contact_category like '%{$item}%'
limit $limit
offset $offset
__________________
Email me | CAPTCHA verification script | DNS speed test | Email address tester | Regex checker | PHP scripts | Do it yourself avatars Cruft free domain names | English Spanish Translation | Watermarking images | Freelance | Texas Holdem Poker Probability Calculator Last edited by bokeh; 05-28-2007 at 12:26 PM. |
|
#4
|
||||
|
||||
|
Hi guys, thanks so much. Unfortunately I cannot get the rewritten code to work. However, the one I posted works fine. It just don't turn the pages with the previews/next button. I think the $s value is passed by the form? I don't get it but the $s value exists and the code makes the sum of $s+ - $limit without a problem. But when I click on the "next" link it wont turn the pages with the next 10 rows. However, If i set the $s value manually, for example to 10 instead of 0, the results automatically shows from the 11th row to the 20th. But the preview/next buttons wont work. Hope this make sense. Other than that, my code querys and gives results flawlessly. Thanks again
__________________
fdkid |
|
#5
|
||||
|
||||
|
just a quick stab at it tonight.
move you $count = 1 + $s ; in side your query while and your next button goes ahead 10 so you may want to have $next = ($count + 1);
__________________
Auckland, New Zealand, Web Design & Hosting. - Inbox Design Sheldon Lendrum, Technology, PHP, Mootools & More... Simple Site a Completely Dynamic site using text files, PHP and no mySQL. |
|
#6
|
||||
|
||||
|
Hi guys. Thanks for all the posts. This must be a silly thing, it doesn't work! I can even see how the $s value changes in the address bar , but it keep showing only the first matches, whatever the $limit value is. I assume the code works correctly but for some reason, the $ value don't has any effect on the code althou is correctly passed to the browser. Please help, stocked on this for good!
__________________
fdkid |
|
#7
|
||||
|
||||
|
Can you post an example to this, like a link so we can see what is going on?
__________________
Auckland, New Zealand, Web Design & Hosting. - Inbox Design Sheldon Lendrum, Technology, PHP, Mootools & More... Simple Site a Completely Dynamic site using text files, PHP and no mySQL. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|