Jump to content

Recommended Posts

im currently making a search facility, and i have come across the problem of having too many results on a single page.

I know the way around this is to display the results into sets of 10 or so, and provide links to "next page" or "11 - 20" etc.

But im not sure exactly how i would go about this. Would the links at the bottom of each page have to link to a separate page which performed the search again, but used the SQL LIMIT function to say LIMIT 10,20 or something along those lines?

Anyone know of any tutorials that cover this??
Link to comment
https://forums.phpfreaks.com/topic/6718-sorting-search-results-into-blocks/
Share on other sites

cheers, thats what i was looking for!!

Now i have another problem! My search sql is playing up! For example, if i search for the word "stan", i know that this only has one occurance in the table im searching. When the search is performed, it brings back 5 results. Each of the results links to the correct entry, but it prints every row in the table in the process (hence bringing back 5 results)

Is there a problem with the query im using?

[code]
$sql = "SELECT table1.user_name, table1.user_id FROM table1, table2
WHERE table2.description LIKE '%" .  $_POST[keywords] . "%'
AND table1.user_id = table2.user_id
AND table2.group_id = '2'";[/code]
If table2 has 5 records that match the id in table1 then you get five rows returned when you you join the tables.

Use the DISTINCT keyword

[code]
$sql = "SELECT DISTINCT table1.user_name, table1.user_id FROM table1, table2
WHERE table2.description LIKE '%" .  $_POST[keywords] . "%'
AND table1.user_id = table2.user_id
AND table2.group_id = '2'";[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.