At 13:21 04/04/00 +0200, you wrote:
>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?
No put it in at the top, after
// get department from ENV
$department = intval($department);
>
>is file://display
>and file://$Chunklength to be saved and put in modules somewhere?
put the following into globalsettings
// how many items to show at a time
$Chunklength = 10;
the section with the print statements is what actually sends it to screen,
I use it twice, top and bottom
Have a look at http://scanwel.co.uk/shop/ (still beta!)
click on departments on the menu
>
>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?
It's not a function
The last line of the code:
$chunk_query="LIMIT " . $chunknext . "," . $Chunklength;
should be inserted into the $Query, eg
//show sub-departments
$Query = "SELECT ID, Name, Graphic, Description ";
$Query .= "FROM department ";
$Query .= "WHERE Parent=$department ";
$Query .= "ORDER BY DisplayPrecedence, Name ";
$Query .= $chunk_query;
do the same for the items $Query
If you can't figure out what's going on then insert temporary print
statements. eg print("CHUNKLAST=$chunklast\n");
>
>Thanks for being patient with a programming novice like myself !
Just roll up your sleeves and get stuck in
>
>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]
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Site: http://www.working-dogs.com/freetrade/
Problems?: [EMAIL PROTECTED]