mike2 Posted May 15, 2014 Share Posted May 15, 2014 (edited) I would like to modify my php script where my PDF search results would not only display the company name, the country, but also display a limit number link by pages so that not all of the results are shown. I also want the first word searched to go to the first occurrence of the word on the PDF document. What would be the best way to do this? Here is my code: <html> <head></head> <body> <?php if (!isset($_POST['q'])) { ?> <img src="/wvb-logo-slogen.png" border="0" /> <h2>Search</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <input type="text" name="q" size="30" /> </form> <?php } else { ?> <img src="/wvb-logo-slogen.png" border="0" /> <h2>Search Results</h2> <?php try { // create object // $swish = new Swish('/usr/local/apache/htdocs/swish/index.swish-e'); $swish = new Swish('/var/www/html/pdf2/index.swish-e'); // get and run query from command-line $queryStr = htmlentities($_POST['q']); $result = $swish->query($queryStr); ?> Found <?php echo $result->hits; ?> match(es) for '<?php echo $queryStr; ?>'. <?php // iterate over result set // print details for each match while($r = $result->nextResult()) { ?> <p> <?php echo $r->swishreccount; ?> <strong> <a href="<?php echo '/pdf2', ltrim($r->swishdocpath, '.') ; ?>"> <?php echo $r->swishdocpath; ?> </a> </strong> (score: <?php echo $r->swishrank; ?>) <br/> <?php echo $r->swishdocpath; ?> </p> <?php } } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } } ?> </body> </html> Any assistance would be greatly appreciated. Edited May 15, 2014 by mac_gyver code tags please Quote Link to comment https://forums.phpfreaks.com/topic/288501-question-about-modifying-search-results-page/ Share on other sites More sharing options...
Ansego Posted May 15, 2014 Share Posted May 15, 2014 Hi, Not to familiar with Swish, but research I have done found two prospects: SwishSearch::resetLimit — Reset the search limits SwishSearch::setLimit — Set the search limits Reference: http://www.php.net/manual/en/book.swish.php Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/288501-question-about-modifying-search-results-page/#findComment-1479526 Share on other sites More sharing options...
mac_gyver Posted May 15, 2014 Share Posted May 15, 2014 Please use the forum's bbcode tags (the edit form's <> button) around your code when posting it. i edited your post above, but you have nearly 50 posts and should know how to use the features specific to a coding forum. Quote Link to comment https://forums.phpfreaks.com/topic/288501-question-about-modifying-search-results-page/#findComment-1479558 Share on other sites More sharing options...
mike2 Posted May 15, 2014 Author Share Posted May 15, 2014 (edited) Hi, Not to familiar with Swish, but research I have done found two prospects: SwishSearch::resetLimit — Reset the search limits SwishSearch::setLimit — Set the search limits Reference: http://www.php.net/manual/en/book.swish.php Hope this helps. Thank you for the information. Actually I am looking to do something a little bit more specific. Allow me to further elaborate. What I want to show up on my search results page is for there to be a drop down menu with the values to be 10 20 or 50 for example and if a user wants to just display 10 results per page than 10 results per page would only be displayed. What I am asking is there a correct way using PHP code to accomplish this task? What would that code even look like and does it even exist? As well as the other questions that I asked above. But that is not to say that I am not going to look into the links you gave me because I will. Do you know anyone familiar with Swish-e who would be able to assist me? Edited May 15, 2014 by mike2 Quote Link to comment https://forums.phpfreaks.com/topic/288501-question-about-modifying-search-results-page/#findComment-1479587 Share on other sites More sharing options...
mike2 Posted May 15, 2014 Author Share Posted May 15, 2014 Hi, Not to familiar with Swish, but research I have done found two prospects: SwishSearch::resetLimit — Reset the search limits SwishSearch::setLimit — Set the search limits Reference: http://www.php.net/manual/en/book.swish.php Hope this helps. One more thing that I would like to mention to you is that I would like to have the names of the companies displayed the names of the actually companies are in a a .csv file located under the same directory that I am running my php search script from. What would I have to put in my PHP search script so that when it runs that it would check the first 12 characters of the PDF title that are in the /var/www/html/pdf2 directory to the /var/www/html/active_colist.csv directory? The .csv file has the first 12 characters of the PDF titles as well as teh corresponding companies. Quote Link to comment https://forums.phpfreaks.com/topic/288501-question-about-modifying-search-results-page/#findComment-1479607 Share on other sites More sharing options...
Ansego Posted May 16, 2014 Share Posted May 16, 2014 Hi Mike2, I've not really used Swish, normally when I work with *.csv files I export the data to a MySQL database then use SQL to retrieve my data. And when I pull the records using SQL I use a SQL condition called LIMIT X Y (or) BETWEEN X Y. I'll have to pass you over to someone with more expertise with CSV. Think what your doing if I remember correctly is called 'Paging'. Re Ansego. Quote Link to comment https://forums.phpfreaks.com/topic/288501-question-about-modifying-search-results-page/#findComment-1479652 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.