Hi!
This is good! Can you explain what I need to do to get it running?
Is the first part to be added at bottom of departments?
is file://display
and file://$Chunklength to be saved and put in modules somewhere?
file://$Chunklength is defined in globalsettings, value 10 (or whatever) Does that
mean I shuld make a new statment in global_settings? What shuld I write?
Also I have been under the impression that making a function for splitting items up
this way will mean that session id no must be included someway. Is this wrong?
Thanks for being patient with a programming novice like myself !
Bjarne Hansen
Oslo Norway
From: Bob Hutchinson <[EMAIL PROTECTED]>
To: FreeTrade <[EMAIL PROTECTED]>
Sent: Tuesday, April 04, 2000 11:14 AM
Subject: Re: [FreeTrade] Search results
> At 21:42 03/04/00 +0200, you wrote:
> >Hi
> >
> >Does any1 know how to get previous/next buttons and the number of
> >matches in a search result?
> >
> >Thanks
> >
> >Tom
> >
> >
>
> Here are some snippets that I use in departments
>
> // $inputchunknext comes from ENV, passed from previous page
> if($inputchunknext){$chunknext = $inputchunknext;}
> else{$chunknext = 0;}
>
> // find total length of search for depts
> $Query = "SELECT ID ";
> $Query .= "FROM department ";
> $Query .= "WHERE Parent=$department ";
> $DatabaseResult = mysql_query($Query, $DatabaseLink);
> $chunklastsub = mysql_num_rows($DatabaseResult);
> // find out length of search for items
> $Query = "SELECT i.ID ";
> $Query .= "FROM item i, department_item di ";
> $Query .= "WHERE di.Department = $department ";
> $Query .= "AND i.ID = di.Item ";
> $DatabaseResult = mysql_query($Query, $DatabaseLink);
> $chunklastitem = mysql_num_rows($DatabaseResult);
> // total number of search
> $chunklast = ($chunklastitem + $chunklastsub);
>
> file://display current dept and calc link to previous dept
> if($department){
> $Query = "SELECT ID, Name, Description, Parent ";
> $Query .= "FROM department ";
> $Query .= "WHERE ID=$department ";
> $Query .= "ORDER BY DisplayPrecedence, Name ";
> $DatabaseResult = mysql_query($Query, $DatabaseLink);
> while($DatabaseRow = mysql_fetch_object($DatabaseResult))
> {
> // display current dept
> print("$DatabaseRow->Description<BR>");
> $deptprev .= "<A HREF=\"";
> $deptprev .= ScreenURL("department.inc");
> $deptprev .= "&department=$DatabaseRow->Parent\">";
> $deptprev .= "< Back to previous Department</A>";
> }
> }
>
> file://$Chunklength is defined in globalsettings, value 10 (or whatever)
>
> // calc what's been found
> $chunkfound = "$chunklast Found";
> if($chunklast > $Chunklength){
> $chunkfound .= " Showing ";
> $chunkfound .= $chunknext + 1;
> $chunkfound .= " to ";
> if(($chunknext + $Chunklength) > $chunklast){
> $chunkfound .= $chunklast;
> }
> else{
> $chunkfound .= $chunknext + $Chunklength;
> }
> }
>
> // calc << First < Previous Next > Last >>
> if(($chunklast > $Chunklength)){
> $Query = "SELECT ID ";
> $Query .= "FROM department ";
> $Query .= "WHERE ID=$department";
> $DatabaseResult = mysql_query($Query, $DatabaseLink);
> while($DatabaseRow = mysql_fetch_object($DatabaseResult))
> {
> // make nav bar
> $navbar = "<TABLE><TR>";
> // first
> $navbar .= "<TD>";
> if($chunknext > 0){
> $navbar .= "<A HREF=\"" . ScreenURL("department.inc") .
> "&department=$DatabaseRow->ID&inputchunknext=0\"><< First</A>";
> }else{$navbar .= " ";}
> $navbar .= "</TD>";
>
> // prev
> $chunk = $chunknext - $Chunklength;
> if($chunk < 0){$chunk = 0;}
> $navbar .= "<TD>";
> if(($chunk >= 0) and ($chunknext > 0)){
> $navbar .= "<A HREF=\"" . ScreenURL("department.inc") .
> "&department=$DatabaseRow->ID&inputchunknext=$chunk\">< Previous</A>";
> }else{$navbar .= " ";}
> $navbar .= "</TD>";
> $navbar .= "<TD> </TD>";
> // next
> $chunk = $chunknext + $Chunklength;
> $navbar .= "<TD>";
> if($chunk < $chunklast){
> $navbar .= "<A HREF=\"" . ScreenURL("department.inc") .
> "&department=$DatabaseRow->ID&inputchunknext=$chunk\">Next ></A>";
> }else{$navbar .= " ";}
> $navbar .= "</FONT></TD>";
> // last
> $navbar .= "<TD>";
> if(($chunknext + $Chunklength) < $chunklast){
> $chunk = ($chunklast - $Chunklength);
> $navbar .= "<A HREF=\"" . ScreenURL("department.inc") .
> "&department=$DatabaseRow->ID&inputchunknext=$chunk\">Last >></A>";
> }else{$navbar .= " ";}
> $navbar .= "</TD>";
> $navbar .= "</TR></TABLE>";
> }
> }
>
> // nav and info
> print("<TABLE><TR>\n");
> print("<TD>\n");
>
> // display link to previous dept
> print($deptprev);
> print(" </TD>\n<TD> \n");
>
> // display what's been found
> print($chunkfound);
> print("</TD></TR></TABLE>\n");
> print($navbar);
>
> // set up limit
> $chunk_query="LIMIT " . $chunknext . "," . $Chunklength;
>
> // add $chunk_query to the search, to limit the display
>
>
> >
> >------------------------------------------------------------
> >To subscribe: [EMAIL PROTECTED]
> >To unsubscribe: [EMAIL PROTECTED]
> >Site: http://www.working-dogs.com/freetrade/
> >Problems?: [EMAIL PROTECTED]
>
>
>
> ------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Site: http://www.working-dogs.com/freetrade/
> Problems?: [EMAIL PROTECTED]
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Site: http://www.working-dogs.com/freetrade/
Problems?: [EMAIL PROTECTED]