Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: SV: Search form is always one item behine the current search


Message #1 by "Datatal AB - Gauffin, Jonas" <Jonas@d...> on Tue, 15 Oct 2002 16:42:49 +0200
<?php

  require("./../adodb/adodb.inc.php");
  require("./../Connections/inventory.php");
?><?php
$KT_numRows_search = 10
?><?php
  $search__MMColParam = "1";
  if (isset($HTTP_GET_VARS["s"])) {
    $search__MMColParam = $HTTP_GET_VARS["s"];
  }
?><?php
  if (isset($KT_Tot) && $KT_Tot!="") {
    if(!isset($KT_numRows_search)){
      $KT_numRows_search=1;
    }
    $KT_index = (int)$KT_index;
    $search = $inventory->SelectLimit("SELECT * FROM Products WHERE
ProductDescription LIKE '%" . ($search__MMColParam) . "%'",
$KT_numRows_search, $KT_index) or
KT_DIE($inventory->ErrorNo(),$inventory->ErrorMsg());
    $search__totalRows = $HTTP_GET_VARS["KT_Tot"];
    $search__isLimited = true;
  } else {
    $search = $inventory->Execute("SELECT * FROM Products WHERE
ProductDescription LIKE '%" . ($search__MMColParam) . "%'") or
KT_DIE($inventory->ErrorNo(),$inventory->ErrorMsg());
    $search__totalRows=$search->RecordCount();
  }
?><?php
   $Repeat1__numRows = 10;
   $Repeat1__index= 0;
   $search_numRows = $search_numRows + $Repeat1__numRows;
?><?php
   $Repeat2__numRows = 10;
   $Repeat2__index= 0;
   $search_numRows = $search_numRows + $Repeat2__numRows;
?><?php require_once(ADODB_DIR."/KTmoveTo_keepParams.php"); ?><?php
  file://MoveTo and Recordset Statistics init vars
  if(!isset($KT_Tot) || $KT_Tot==""){
    $KT_Tot=$search__totalRows;
  }
  if(!isset($KT_index) || $KT_index==""){
    $KT_index=0;
  }
  if(!isset($KT_numRows_search)){
    $KT_numRows_search=1;
  }
  if($KT_index>=$KT_Tot){
    $KT_index=0;
  }
  if($KT_index<0){
    $KT_index=0;
  }
?><?php
  file://handle Recordset Statistics
  $search_total = $KT_Tot;
  $search_first  = min($KT_Tot, $KT_index+1);
  $search_last  = min(max($search_first, $KT_index+$KT_numRows_search),
$KT_Tot);
?><?php
  file://handle MoveTo vars and links
  $MM_offset = $KT_index;
  $MM_atTotal = ($search_last == $search_total);
  $KT_toPrev = max(0, $KT_index-$KT_numRows_search);
  $KT_toLast = max(0, $KT_Tot-$KT_Tot%$KT_numRows_search);
  if($KT_toLast == $KT_Tot){
    $KT_toLast = max(0, $KT_Tot-$KT_numRows_search);
  }
  $KT_toNext = min($KT_index+$KT_numRows_search, $KT_toLast);
  $MM_moveFirst = $MM_movePrev = $MM_moveNext = $MM_moveLast 
$PHP_SELF."?".$MM_keepBoth;

  addReplaceParam(&$MM_moveFirst, "KT_index", 0);
  addReplaceParam(&$MM_moveFirst, "KT_Tot", $KT_Tot);

  addReplaceParam(&$MM_movePrev, "KT_index", $KT_toPrev);
  addReplaceParam(&$MM_movePrev, "KT_Tot", $KT_Tot);

  addReplaceParam(&$MM_moveNext, "KT_index", $KT_toNext);
  addReplaceParam(&$MM_moveNext, "KT_Tot", $KT_Tot);

  addReplaceParam(&$MM_moveLast, "KT_index", $KT_toLast);
  addReplaceParam(&$MM_moveLast, "KT_Tot", $KT_Tot);

  if(!isset($search__isLimited)){
    for($KT_i=0;$KT_i<$KT_index;$KT_i++){
      $search->MoveNext();
    }
  }
?>


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="/stylesheets/sitewide.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<table width="355" border="0" cellspacing="0" cellpadding="0" height="39">
  <tr>
    <td>
      <?php include(".././headertopnavbar/navbar2.html");?>
    </td>
  </tr>
</table>
<table width="699" border="0" cellspacing="0" cellpadding="0" height="49">
  <tr>
    <td align="right" valign="top"><!-- #BeginLibraryItem
"/Library/javascriptdate.lbi" --><font face="Verdana, Arial, Helvetica,
sans-serif" size="1" color="#0000CC"><b><script language="JavaScript"
src="/jscript/date.js">

</script></b></font><!-- #EndLibraryItem --></td>
  </tr>
</table>
<table width="682" border="0" cellspacing="0" cellpadding="0" height="63"
bordercolor="#330099">
  <tr>
    <td align="left" valign="top" width="631">
      <?php while (($Repeat2__numRows-- != 0) && (!$search->EOF))
   {
?>
      <table width="620" border="0" cellspacing="0" cellpadding="0"
bordercolor="#333399">
        <tr>
          <td colspan="2">&nbsp; </td>
        </tr>
        <tr>
          <td colspan="2" class="producttableheader">
            <?php echo $search->Fields("ProductName")?>
          </td>
        </tr>
        <tr>
          <td width="159" class="productdbspecifics"> <a
href=".././inv/proddetails.php?pn=<?php echo
$search->Fields("ItemNumber")?>">
            <?php echo $search->Fields("ItemNumber")?>
            </a> </td>
          <td width="461" class="productdbspecifics">
            <?php echo $search->Fields("ProductDescription")?>
          </td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
      </table>
      <?php
  $Repeat2__index++;
  $search->MoveNext();
}
?>
    </td>
    <td align="left" valign="top" width="51">&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
<table width="713" border="1" cellspacing="10" cellpadding="0"
bordercolor="#CC6699">
  <?php while (($Repeat1__numRows-- != 0) && (!$search->EOF))
   {
?>
  <tr>
    <td width="147" align="left" valign="top" height="74"
bordercolor="#0000FF">
      <table width="75" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td>
            <?php echo $search->Fields("ProductName")?>
          </td>
        </tr>
        <tr>
          <td><a href=".././inv/proddetails.php?pn=<?php echo
$search->Fields("ItemNumber")?>">
            <?php echo $search->Fields("ItemNumber")?>
            </a></td>
        </tr>
      </table>
    </td>
    <td width="424" rowspan="2" align="left" valign="top"
bordercolor="#0000FF">
      <?php echo $search->Fields("ProductDescription")?>
    </td>
    <td width="142" rowspan="2" align="left" valign="top">&nbsp; </td>
  </tr>
  <?php
  $Repeat1__index++;
  $search->MoveNext();
}
?>
</table>
<table border="0" width="50%" align="center">
  <tr>
    <td width="23%" align="center">
      <?php if ($MM_offset != 0) { ?>
      <a href="<?php echo $MM_moveFirst?>"><img src="First.gif"
border=0></a>
      <?php } // end $MM_offset != 0 ?>
    </td>
    <td width="31%" align="center">
      <?php if ($MM_offset != 0) { ?>
      <a href="<?php echo $MM_movePrev?>"><img src="Previous.gif"
border=0></a>
      <?php } // end $MM_offset != 0 ?>
    </td>
    <td width="23%" align="center">
      <?php if (!$MM_atTotal) { ?>
      <a href="<?php echo $MM_moveNext?>"><img src="Next.gif" border=0></a>
      <?php } // end !$MM_atTotal ?>
    </td>
    <td width="23%" align="center">
      <?php if (!$MM_atTotal) { ?>
      <a href="<?php echo $MM_moveLast?>"><img src="Last.gif" border=0></a>
      <?php } // end !$MM_atTotal ?>
    </td>
  </tr>
</table>
<p>&nbsp;</p>
<table width="619" border="0" cellspacing="0" cellpadding="0" height="34">
  <tr>
    <td align="center" valign="top"><img src="/footernavbar/footer.jpg"
width="281" height="11"></td>
  </tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
<?php
  $search->Close();
?>



THIS E-MAIL MESSAGE AND ALL ATTACHMENTS TRANSMITTED HEREWITH ARE TRADE
SECRET AND/OR CONFIDENTIAL INFORMATION INTENDED ONLY FOR THE VIEWING AND
USE OF ADDRESSEE.  IF THE READER OF THIS MESSAGE IS NOT THE INTENDED
RECIPIENT, YOU ARE HEREBY NOTIFIED THAT ANY REVIEW, USE, COMMUNICATION,
DISSEMINATION, DISTRIBUTION OR COPYING OF THIS COMMUNICATION IS PROHIBITED.
IF YOU HAVE RECEIVED THIS COMMUNICATION IN ERROR, PLEASE NOTIFY THE SENDER
IMMEDIATELY BY TELEPHONE OR ELECTRONIC MAIL, AND DELETE THIS MESSAGE AND
ALL COPIES AND BACKUPS THEREOF.  THANK YOU FOR YOUR COOPERATION.

-----Original Message-----
From: Datatal AB - Gauffin, Jonas <Jonas@d...>
To: professional php <pro_php@p...>
Date: Tuesday, October 15, 2002 9:52 AM
Subject: [pro_php] SV: Search form is always one item behine the current
search


That is not your search code. Its your search form. Show us your code.

> -----Ursprungligt meddelande-----
> Från: Darrian Walker [mailto:dwalker@h...]
> Skickat: den 15 oktober 2002 16:29
> Till: professional php
> Ämne: [pro_php] Search form is always one item behine the
> current search
>
>
> Search form is always one item behind the current search.
> I have a form (whose code I've included) that always want to
> display one item previous to the current item to be search.
> Example: If I search for 5 different things like :
>
> Current Search Displayed Search Item
> A
> B ----------------------------->A
> C ------------------------------>B
> D ------------------------------>C
>
>
> How do I get my search form to display the current search item?
>
> Current Search Displayed Search Item
> A ----------------------------------------->A
> B ----------------------------------------->B
> C ----------------------------------------->C
>
> Here's my code:
>
> <?php $s=($HTTP_POST_VARS["s"]);?>
> <html>
> <form name="form1" method="post"
> action="/cust/search.php?s=<?php echo $s?>"> <input
> type="text" name="s" size="12" maxlength="255" value="Search"
> height="5" border="0"> <input type="image" name="Submit"
> value="Image" src="/siteimages/greengo.gif" border="0"> </form></html>
>
>
>
>
> THIS E-MAIL MESSAGE AND ALL ATTACHMENTS TRANSMITTED HEREWITH
> ARE TRADE SECRET AND/OR CONFIDENTIAL INFORMATION INTENDED
> ONLY FOR THE VIEWING AND USE OF ADDRESSEE.  IF THE READER OF
> THIS MESSAGE IS NOT THE INTENDED RECIPIENT, YOU ARE HEREBY
> NOTIFIED THAT ANY REVIEW, USE, COMMUNICATION, DISSEMINATION,
> DISTRIBUTION OR COPYING OF THIS COMMUNICATION IS PROHIBITED.
> IF YOU HAVE RECEIVED THIS COMMUNICATION IN ERROR, PLEASE
> NOTIFY THE SENDER IMMEDIATELY BY TELEPHONE OR ELECTRONIC
> MAIL, AND DELETE THIS MESSAGE AND ALL COPIES AND BACKUPS
> THEREOF.  THANK YOU FOR YOUR COOPERATION.
>
>
>
>
>





  Return to Index