4Guys script enhancement

Results 1 to 2 of 2

Thread: 4Guys script enhancement

  1. #1
    Join Date
    Dec 1969

    Default 4Guys script enhancement

    I&#039;m using this 4guys script:<BR><BR>http://www.4guysfromrolla.com/webtech/120499-1.shtml<BR><BR>I would like to enhance it to include paging with total number of results and numbering of the results.<BR><BR>Can you point me in the right direction?<BR><BR>Any help appreciated.

  2. #2
    Join Date
    Dec 1969

    Default No practical way...

    ...to do that, in general.<BR><BR>That code simply grabs 10 "hits" and remembers the file name where it "left off". When it comes back, it has to start at the beginning again and skip files until it finds where it left off. Etc.<BR><BR>To get the total number of results, you&#039;d have to *FIRST* process *ALL* the files. And then you&#039;d have to do it again as you did the paging.<BR><BR>*************<BR><BR>If you want to do this, scrap that paging code and invent your own.<BR><BR>On the first "hit", indeed scan all the files. And put the names of files where a match was found into an array. Save the array in a session variable. <BR><BR>Now the number of elements in the array is the total number of results and the index into the array gives you the numbering.<BR><BR>You simply display page-size results each time and can move to any result (or set of page-size results) at any time.<BR><BR>Advantages: Generally simpler coding. Gives you the numbering you wanted.<BR><BR>Disadvantages: You have to scan *all* files for matches before you can display even the first page; if there are many files, this could be agonizingly slow. You need an array saved in a session variable. Fine for a not-too-busy sited. Could overload things on a really busy site. ("Busy" = more than a couple of thousand hits that use this search feature per hour.)<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts