cssmatt Posted April 6, 2006 Share Posted April 6, 2006 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?? Quote Link to comment https://forums.phpfreaks.com/topic/6718-sorting-search-results-into-blocks/ Share on other sites More sharing options...
ToonMariner Posted April 6, 2006 Share Posted April 6, 2006 As if by magic....[a href=\"http://www.phpfreaks.com/tutorial_cat/25/Page-Number--Pagination.php\" target=\"_blank\"]Pagination[/a] Quote Link to comment https://forums.phpfreaks.com/topic/6718-sorting-search-results-into-blocks/#findComment-24411 Share on other sites More sharing options...
cssmatt Posted April 6, 2006 Author Share Posted April 6, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/6718-sorting-search-results-into-blocks/#findComment-24420 Share on other sites More sharing options...
Barand Posted April 6, 2006 Share Posted April 6, 2006 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, table2WHERE table2.description LIKE '%" . $_POST[keywords] . "%'AND table1.user_id = table2.user_idAND table2.group_id = '2'";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/6718-sorting-search-results-into-blocks/#findComment-24628 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.