Jump to content

Question about modifying search results page


mike2

Recommended Posts

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.