05. februar 2008 - 17:28
				#9
						
		 
		
			<?php
session_start();
require("brugttilpaahaeng_connect.php");
$Link = mysql_connect ($Host, $User, $Password);
mysql_select_db($DBName, $Link); 
// hardwired stuff here --------------------------
$THISuniqueID = "brugttilpaahaeng_2347";
$lineIndex = 0;
$linkCount = 0;
$itemNumber = 0;
$get = 0;
$post = 0;
$newID = 0;
$prefix = "";
$suffix = "";
$RFvar = "";
$rows_per_page = 10;
$asapPages = 1;
$screen = 1;
$preOrder = " ORDER BY brugttilpaahaeng.";
$thumb_prefix = "";
$thumb_suffix = "";
//below gets the ascending / descending going
//below is for the first time
if(!isset($HTTP_SESSION_VARS['ASCDESC_brugttilpaahaeng_2347']))
{
    $ASCDESC = " ASC";
    $HTTP_SESSION_VARS['ASCDESC_brugttilpaahaeng_2347'] = $ASCDESC;
}
else
{
  //below is if session is set and we have clicked on a heading
  if(isset($HTTP_GET_VARS['asapSB']))
  {
        if($HTTP_GET_VARS['asapSB'] == $HTTP_SESSION_VARS['asapSB_brugttilpaahaeng_2347'])
      {
        // below is if we have clicked on the same heading
          if($HTTP_SESSION_VARS['ASCDESC_brugttilpaahaeng_2347'] == " ASC")
              $ASCDESC = " DESC";
            else
              $ASCDESC = " ASC";
            $HTTP_SESSION_VARS['ASCDESC_brugttilpaahaeng_2347'] = $ASCDESC;
      }
        else
      {
        // below is if we have clicked on a different heading
            $ASCDESC = " ASC";
            $HTTP_SESSION_VARS['ASCDESC_brugttilpaahaeng_2347'] = $ASCDESC;
        }
  }
    else
    {
      $ASCDESC = $HTTP_SESSION_VARS['ASCDESC_brugttilpaahaeng_2347'];
    }
}
if ($ASCDESC == " ASC")
  $asapWD = "▼";
else
  $asapWD = "▲";
// below gets the sortby going
if(isset($HTTP_GET_VARS['asapSB']))
{
  $asapSB = $HTTP_GET_VARS['asapSB'];
    $HTTP_SESSION_VARS['asapSB_brugttilpaahaeng_2347'] = $asapSB;
}
else
{
  if(!isset($HTTP_SESSION_VARS['asapSB_brugttilpaahaeng_2347']))
  {
      $asapSB = "field8";
      $HTTP_SESSION_VARS['asapSB_brugttilpaahaeng_2347'] = $asapSB;
  }
    else
    {
      $asapSB = $HTTP_SESSION_VARS['asapSB_brugttilpaahaeng_2347'];
    }
}
// keyword functions here ------------------------
function Exact($whereclause,$fieldname,$strInput,$selCrit)
{
  $whereclause = $whereclause . " (" . $fieldname . " LIKE '";
    $whereclause = $whereclause . $strInput . "') AND ";
    //echo "<br>" . $whereclause;
    return $whereclause;
}
function Keywrd($whereclause,$fieldname,$strInput,$selCrit)
{
  $arrSearch = explode(" ",$strInput);
    $strCombine = implode("%') " . $selCrit . " (" . $fieldname . " LIKE '%",$arrSearch);
  $whereclause = $whereclause . " (" . $fieldname . " LIKE '%" . $strCombine . "%') AND ";
    //echo "<br>" . $whereclause;
    return $whereclause;
}
// end keyword functions
// iframe stuff here ------------------------------
if (isset($HTTP_GET_VARS['asapIfr']))
{
    $asapIfr = $HTTP_GET_VARS['asapIfr'];
    $HTTP_SESSION_VARS['asapIfr_brugttilpaahaeng_2347'] = $asapIfr;
}
if (isset($HTTP_SESSION_VARS['asapIfr_brugttilpaahaeng_2347']))
    $asapIfr = $HTTP_SESSION_VARS['asapIfr_brugttilpaahaeng_2347'];
if(isset($HTTP_GET_VARS['asapNOIfr']))
{
        unset($asapIfr);
        unset($HTTP_SESSION_VARS['asapIfr_brugttilpaahaeng_2347']);
}
// looking for uniqueID information here ---------------------------
if (!isset($HTTP_SESSION_VARS['uniqueID_brugttilpaahaeng_2347']))
{
     $uniqueID = "brugttilpaahaeng_2347";
     $uniqueID_brugttilpaahaeng_2347 = $uniqueID;
    $HTTP_SESSION_VARS['uniqueID'] = $uniqueID;
}
if (isset($HTTP_SESSION_VARS['uniqueID_brugttilpaahaeng_2347']))
{
     if ($HTTP_SESSION_VARS['uniqueID_brugttilpaahaeng_2347'] <> $THISuniqueID)
     {
         $newID = 1;
         $HTTP_SESSION_VARS['uniqueID_brugttilpaahaeng_2347'] = $THISuniqueID;
     }
}
// looking for related field here
if (isset($HTTP_GET_VARS['asapRF']))
{
  $asapRF = $HTTP_GET_VARS['asapRF'];
  if ($asapRF <> "")
  {
      $RFvar = $HTTP_GET_VARS['RFvar'];
      switch ($asapRF) {
         case "field1";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field8";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field23";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field24";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field2";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field3";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field4";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field5";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field6";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field7";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field9";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field10";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field11";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field12";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field13";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field14";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field15";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field16";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field17";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field18";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field19";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field20";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field21";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "field22";
         $RFvar = "'" . $RFvar . "'";
          break;
         case "ID";
         $RFvar = $RFvar;
         break;
     }
      $get = 1;
  }
}
// looking for variables from url HTTP_GET_VARS ------------------------------
if (isset($HTTP_GET_VARS['begin_search']))
{
     $get = 1;
}
if (isset($HTTP_GET_VARS['field8']))
{
     $field8 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['field8'] : addslashes($HTTP_GET_VARS['field8']);
     $get = 1;
}
if ($get == 1)
{
     $whereclause = "WHERE ";
     //this is strictly for a related field
     if ($asapRF <> "")
      $whereclause = $whereclause . "brugttilpaahaeng." . $asapRF . " = " .  $RFvar . " AND ";
     if (isset($field8))
         $whereclause = $whereclause . "brugttilpaahaeng.field8 LIKE '%" . $field8 . "%' AND ";
     if ( substr($whereclause,-5) == " AND ")
         $whereclause = substr_replace($whereclause,"",-5);  // strip off ' AND'
     elseif ( substr($whereclause,-4) == " OR ")
         $whereclause = substr_replace($whereclause,"",-4);  // strip off ' OR'
     else
         $whereclause = substr_replace($whereclause,"",-6);  // strip off 'WHERE '
         $whereclause_brugttilpaahaeng_2347 = $whereclause;  // sets unique whereclause
     if (!isset($HTTP_SESSION_VARS['whereclause_brugttilpaahaeng_2347']))
         $HTTP_SESSION_VARS['whereclause_brugttilpaahaeng_2347'] = $whereclause;
     else
         $HTTP_SESSION_VARS['whereclause_brugttilpaahaeng_2347'] = $whereclause;
     $fullOrderBy = " ORDER BY brugttilpaahaeng.field8";
     $fullOrderBy_brugttilpaahaeng_2347 = $fullOrderBy;   // sets unique fullOrderBy
     if (!isset($HTTP_SESSION_VARS['fullOrderBy_brugttilpaahaeng_2347']))
         $HTTP_SESSION_VARS['fullOrderBy_brugttilpaahaeng_2347'] = $fullOrderBy;
     else
         $HTTP_SESSION_VARS['fullOrderBy_brugttilpaahaeng_2347'] = $fullOrderBy;
}
// looking for variables from search form HTTP_POST_VARS -----------------------------
if (isset($HTTP_POST_VARS['field8']))
{
     $field8 = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['field8'] : addslashes($HTTP_POST_VARS['field8']);
     $post = 1;
}
if ($post == 1)
{
     $whereclause = "WHERE ";
     if ($field8 <> "")
         $whereclause = $whereclause . "brugttilpaahaeng.field8 LIKE '%" . $field8 . "%' AND ";
     if ( substr($whereclause,-5) == " AND ")
         $whereclause = substr_replace($whereclause,"",-5);  // strip off ' AND'
     elseif ( substr($whereclause,-4) == " OR ")
         $whereclause = substr_replace($whereclause,"",-4);  // strip off ' OR'
     else
         $whereclause = substr_replace($whereclause,"",-6);  // strip off 'WHERE '
         $whereclause_brugttilpaahaeng_2347 = $whereclause;  // this sets unique whereclause
     if (!isset($HTTP_SESSION_VARS['whereclause_brugttilpaahaeng_2347']))
         $HTTP_SESSION_VARS['whereclause_brugttilpaahaeng_2347'] = $whereclause;
     else
         $HTTP_SESSION_VARS['whereclause_brugttilpaahaeng_2347'] = $whereclause;
     $fullOrderBy = " ORDER BY brugttilpaahaeng.field8";
     $fullOrderBy_brugttilpaahaeng_2347 = $fullOrderBy;   // this sets unique fullOrderBy
     if (!isset($HTTP_SESSION_VARS['fullOrderBy_brugttilpaahaeng_2347']))
         $HTTP_SESSION_VARS['fullOrderBy_brugttilpaahaeng_2347'] = $fullOrderBy;
     else
         $HTTP_SESSION_VARS['fullOrderBy_brugttilpaahaeng_2347'] = $fullOrderBy;
}
// looking to see if we've received some commands to orderby a certain field //
if (isset($HTTP_GET_VARS['asapSB']))
{
     $asapSB = $HTTP_GET_VARS['asapSB'];
     $fullOrderBy = $preOrder . $asapSB . $ASCDESC;
     $HTTP_SESSION_VARS['fullOrderBy_brugttilpaahaeng_2347'] = $fullOrderBy;
     $whereclause = $HTTP_SESSION_VARS['whereclause_brugttilpaahaeng_2347'];
}
// looking to see if search without search form and reusing session if set //
if ($get == 0 && $post == 0)
{
     if (!isset($HTTP_SESSION_VARS['fullOrderBy_brugttilpaahaeng_2347']))
     {
         $fullOrderBy = " ORDER BY brugttilpaahaeng.field8";
         $fullOrderBy_brugttilpaahaeng_2347 = $fullOrderBy;  // sets unique fullOrderBy
         $HTTP_SESSION_VARS['fullOrderBy_brugttilpaahaeng_2347'] = $fullOrderBy;
     }
     else
     {
         if($newID == 1)
         {
             $fullOrderBy = " ORDER BY brugttilpaahaeng.field8";
             $HTTP_SESSION_VARS['fullOrderBy_brugttilpaahaeng_2347'] = $fullOrderBy;
         }
         else
             $fullOrderBy = $HTTP_SESSION_VARS['fullOrderBy_brugttilpaahaeng_2347'];
     }
     if (!isset($HTTP_SESSION_VARS['whereclause_brugttilpaahaeng_2347']))
     {
         $whereclause = "WHERE ";
         if ( substr($whereclause,-5) == " AND ")
             $whereclause = substr_replace($whereclause,"",-5);  // strip off ' AND'
         elseif ( substr($whereclause,-4) == " OR ")
             $whereclause = substr_replace($whereclause,"",-4);  // strip off ' OR'
         else
             $whereclause = substr_replace($whereclause,"",-6);  // strip off 'WHERE '
             $whereclause_brugttilpaahaeng_2347 = $whereclause;   // sets unique whereclause
             $HTTP_SESSION_VARS['whereclause_brugttilpaahaeng_2347'] = $whereclause;
     }
     else
     {
         if($newID == 1)
         {
             $whereclause = "WHERE ";
             if ( substr($whereclause,-5) == " AND ")
                 $whereclause = substr_replace($whereclause,"",-5);  // strip off ' AND'
             elseif ( substr($whereclause,-4) == " OR ")
                 $whereclause = substr_replace($whereclause,"",-4);  // strip off ' OR'
             else
                 $whereclause = substr_replace($whereclause,"",-6);  // strip off 'WHERE '
                 $HTTP_SESSION_VARS['whereclause_brugttilpaahaeng_2347'] = $whereclause;
         }
         else
             $whereclause = $HTTP_SESSION_VARS['whereclause_brugttilpaahaeng_2347'];
     }
}
// for deleting multiple records
if(isset($HTTP_POST_VARS['Delete']))
{
   $remove = $HTTP_POST_VARS['Delete'];
   $n        = count($remove);
   $i        = 0;
   while ($i < $n)
   {
      $delQuery = "DELETE FROM brugttilpaahaeng WHERE brugttilpaahaeng.ID = " . $remove[$i];
      if ($Result = mysql_query($delQuery, $Link))
    {
          $i++;
    }
   }
}
$Count = "SELECT ID,field1,field8,field23,field24,field2,field3,field4,field5,field6,field7,field9,field10,field11,field12,field13,field14,field15,field16,field17,field18,field19,field20,field21,field22 FROM brugttilpaahaeng " . $whereclause;
$Recordset = mysql_query($Count, $Link);
if (!isset($total_records))
{
     $total_records = mysql_num_rows($Recordset);
     $total_results = $total_records - 1;
     $total_results_brugttilpaahaeng_2347 = $total_results;  // sets unique total_results
     if (!isset($HTTP_SESSION_VARS['total_results_brugttilpaahaeng_2347']))
             $HTTP_SESSION_VARS['total_results_brugttilpaahaeng_2347'] = $total_results;
     else
             $HTTP_SESSION_VARS['total_results_brugttilpaahaeng_2347'] = $total_results;
}
$asapPages = ceil($total_records / $rows_per_page);
 mysql_free_result($Recordset);
//  looking for request of screen number (alias Page Number) //
if (!isset($HTTP_GET_VARS['screen']))
     $screen = 1;
else
     $screen = $HTTP_GET_VARS['screen'];
// loooking for screen number from delete function
if (isset($HTTP_POST_VARS['screen']))
     $screen = $HTTP_POST_VARS['screen'];
$start = ($screen - 1) * $rows_per_page;
// Querying database here //
$Query = "SELECT ID,field1,field8,field23,field24,field2,field3,field4,field5,field6,field7,field9,field10,field11,field12,field13,field14,field15,field16,field17,field18,field19,field20,field21,field22";
$Query = $Query . " FROM brugttilpaahaeng " . $whereclause . $fullOrderBy . " LIMIT $start, $rows_per_page";
$Recordset = mysql_query($Query, $Link);
$rows = mysql_num_rows($Recordset);
// this is the total number of chapters holding the pages //
$asapChapters = ceil($asapPages / 10);
// this is the current chapter //
$asapChapter = ceil($screen * .1);
// this would be the first page in the current chapter //
$start10 = ($asapChapter * 10) - 9;
// this would be the last page in the current chapter //
$stop10 = $asapChapter * 10;
if ($stop10 > $asapPages)
{
  $stop10 = $asapPages;
}
$next1 = $stop10 + 1;
$previous1 = $start10 - 1;
$Next = "brugttilpaahaeng_search_results.php?screen=" . $next1;
$Previous = "brugttilpaahaeng_search_results.php?screen=" . $previous1;
     $prefix = "location.href='";
     $suffix = "'";
?>
<html>
<head>
<title>Havnens Marine Service APSbrugttilpaahaeng Search Results</title>
<SCRIPT LANGUAGE=JAVASCRIPT>
<!-- Hide script form old browsers
var win=null;
function newWindow(url) {
var winl = (screen.width-500)/2;
var wint = (screen.height-500)/2;
 mapWindow = window.open(url, 'ASaP','left='+winl+',top='+wint+',width=500,height=500,scrollbars=yes')
}
// End hiding script from old browsers -->
</SCRIPT>
<meta name="generator" content="Data ASap v3.3.85">
<link rel="stylesheet" href="brugttilpaahaeng_styles.css" type="text/css">
</head>
<body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 link='##4E5B70' alink='##4E5B70' vlink='##4E5B70'>
<?php
     require("brugttilpaahaeng_header.inc");
?>
<div align="center"> 
<table width="800" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <table width="100%" border="0" cellpadding="2" cellspacing="0">
        <tr> 
          <td width="10" class="strip"> </td>
          <td width="10" class="strip"> </td>
          <td class="strip" onmouseover="this.className='strip',this.style.cursor='pointer'" onclick="location.href='brugttilpaahaeng_search_results.php?asapSB=field1&screen=<?php echo $screen; ?>',this.className='strip'">
           <?php
           if ($asapSB == 'field1')
           {
           ?>
           <?php echo $asapWD; ?>
           <?php
           }
           ?>
           <span class='strip'>Billede</span>
           </td>
          <td class="strip" onmouseover="this.className='strip',this.style.cursor='pointer'" onclick="location.href='brugttilpaahaeng_search_results.php?asapSB=field8&screen=<?php echo $screen; ?>',this.className='strip'">
           <?php
           if ($asapSB == 'field8')
           {
           ?>
           <?php echo $asapWD; ?>
           <?php
           }
           ?>
           <span class='strip'>Mærke</span>
           </td>
          <td class="strip" onmouseover="this.className='strip',this.style.cursor='pointer'" onclick="location.href='brugttilpaahaeng_search_results.php?asapSB=field23&screen=<?php echo $screen; ?>',this.className='strip'">
           <?php
           if ($asapSB == 'field23')
           {
           ?>
           <?php echo $asapWD; ?>
           <?php
           }
           ?>
           <span class='strip'>Beskrivelse</span>
           </td>
          <td class="strip" onmouseover="this.className='strip',this.style.cursor='pointer'" onclick="location.href='brugttilpaahaeng_search_results.php?asapSB=field24&screen=<?php echo $screen; ?>',this.className='strip'">
           <?php
           if ($asapSB == 'field24')
           {
           ?>
           <?php echo $asapWD; ?>
           <?php
           }
           ?>
           <span class='strip'>Pris i Kr. incl. moms</span>
           </td>
</tr>
<?php
for ($i = 0; $i < $rows; $i++)
{
     while ($Row = mysql_fetch_assoc($Recordset)) 
     {
         $newitemNumber = (($screen - 1) * $rows_per_page) + $itemNumber;
         $resultLink = $prefix . "brugttilpaahaeng_detail.php?key=" . $Row['ID'] . "&itemNumber=" . $newitemNumber . $suffix;
         if ($lineIndex % 2 == 0)
         {
?>
<tr class="data1" onmouseover="this.style.cursor='pointer'" onclick="<?php echo $resultLink; ?>">
          <td width="10"> </td>
          <td width="100" class="data1">
         <img src='<?php echo $thumb_prefix?><?php echo $Row['field1']; ?><?php echo $thumb_suffix?>' width='90' border='1'>
         </td>
          <td><?php echo $Row['field1']; ?></td>
          <td><?php echo $Row['field8']; ?></td>
          <td><?php echo $Row['field23']; ?></td>
          <td><?php echo $Row['field24']; ?></td>
</tr>
<?php
}
else
{
?>
<tr class="data2" onmouseover="this.style.cursor='pointer'" onclick="<?php echo $resultLink; ?>">
          <td width="10"> </td>
          <td width="100" class="data2">
         <img src='<?php echo $thumb_prefix?><?php echo $Row['field1']; ?><?php echo $thumb_suffix?>' width='90' border='1'>
         </td>
          <td><?php echo $Row['field1']; ?></td>
          <td><?php echo $Row['field8']; ?></td>
          <td><?php echo $Row['field23']; ?></td>
          <td><?php echo $Row['field24']; ?></td>
</tr>
<?php
  }
  $itemNumber = $itemNumber + 1;
  $lineIndex = $lineIndex + 1;
}
}
?>
</table>
    </td>
  </tr>
  <tr>
    <td class="strip"> Records = <?php echo $total_records; ?></td>
  </tr>
</table>
<br><br>
<?php
$previousurl = "brugttilpaahaeng_search_results.php?" . SID . "&screen=" . ($screen - 1);
$nexturl = "brugttilpaahaeng_search_results.php?" . SID . "&screen=" . ($screen + 1);
?>
<div align="center">
<table border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td width="35%"> 
        <div align="center"> 
                  <?php
if ($screen > 1 && $screen < $asapPages)
{
?>
                <div align="center"> 
                  <p><a class="button" href="<?php echo $previousurl; ?>">PREVIOUS</a></p>
                </div>
          
        </div>
      </td>
      <td width="30%"> 
        <div align="center"> </div>
      </td>
      <td width="35%"> 
        <div align="center">
<?php
}
elseif ($screen > 1 && $screen == $asapPages)
{
?>
                <div align="center"> 
                  <p><a class="button" href="<?php echo $previousurl; ?>">PREVIOUS</a></p>
                </div>
<?php
}
elseif ($screen < $asapPages && $screen == 1)
{
?>
                <div align="center"> 
                  <p><a class="button" href="<?php echo $nexturl; ?>">NEXT</a></p>
                </div>
<?php
}
if ($screen < $asapPages && $screen > 1)
{
?>
                <div align="center"> 
                  <p><a class="button" href="<?php echo $nexturl; ?>">NEXT</a></p>
                </div>
<?php
}
?>
        </div>
      </td>
    </tr>
  </table>
  <br>
<?php
if ($total_records == 0)
{
?>
  <b><span class='pagetext'>Sorry, no records in the database matched your search parameters. Click Back and try again. </span></b>
<?php
}
?>
</div>
<div align="center">
<table cellpadding="0" cellspacing="2">
<?php
if ($asapChapter > 1)
{
?>
<td>
<a class='links' href='<?=$Previous?>'>10 PREVIOUS</a>
</td>
<?php
}
// loops through entire range of numbers
for ($i = $start10; $i <= $stop10; $i++)
{
$URL = "brugttilpaahaeng_search_results.php?screen=" . $i;
  if ($i == $screen)
    {
    ?>
    <td>
    <table border="1" bordercolor="#000000" cellpadding="0" cellspacing="0">
    <tr>
    <td class="pageselected" bgcolor="#cccccc" valign="bottom" width="15"><?php echo $i; ?></td>
    </tr>
    </table>
    </td>
    <?php
    }
    else
    {
    ?>
  <td valign="bottom"><b>
  <a class='links' href='<?=$URL?>'><?=$i?></a></b>
    </td>
    <?php
    }
}
if ($asapChapter < $asapChapters)
{
?>
<td>
<a class='links' href='<?=$Next?>'>NEXT 10</a>
</td>
<?php
}
?>
</tr>
</table>
<?php
 mysql_free_result($Recordset);
?>
</td>
</tr>
</table>
</div>
</body>
</html>