<?php
session_start();
include ('dbf.php');
if($_GET[selpage])
{
  $_SESSION[selpage]=$_GET[selpage];
  $_SESSION[ser]='0';
  $_SESSION[ro]='0';
  $_SESSION[start]='0';
  $_SESSION[sf]='city';
  include ($_SESSION[selpage]);

}
elseif($_GET[selpage1])
{
  $_SESSION[selpage]=$_GET[selpage1];
  $_SESSION[ser]='0';
  include ($_SESSION[selpage]);

}
elseif($_GET[selpage2])
{
  $_SESSION[selpage]=$_GET[selpage2];
  $_SESSION[ser]='0';
  $_SESSION[prm]=$_GET['v'];
  include ($_SESSION[selpage]);

}
elseif($_GET[selpage3])
{
  $_SESSION[selpage]=$_GET[selpage3];
  $_SESSION[ser]='0';
  include ($_SESSION[selpage]);

}
elseif($_GET[serpage])
{
  $_SESSION['field']=$_GET[fiel];
  //echo $_SESSION['field'];
   $_SESSION['sear']=$_GET['txt'];
   //echo  $_SESSION['sear'];
  $_SESSION[selpage]=$_GET[serpage];
  include ($_SESSION[selpage]);


}
elseif($_GET[o])
{
$_SESSION[strt]='1';
$_SESSION[ro]='0';
if($_GET[so1]=='1')
  $_SESSION[ser]='1';
$_SESSION[start]=$_GET[paging1];
//echo $_SESSION[selpage];
include ($_SESSION[selpage]);
}
elseif($_GET[printpage])
{
$_SESSION[selpage]=$_GET[printpage];
$_SESSION[printback]=$_GET[prtback];
include ($_SESSION[selpage]);
}
elseif(isset($_GET['back']))
{
  $_SESSION[selpage]=$_SESSION[printback];
  include_once('login.php');

}
elseif($_GET[out])
{
$_SESSION[selpage]=$_GET[out];
$_SESSION[printback]=$_GET[prtback];
include ($_SESSION[selpage]);
}
if($_GET[serch])
{
// $_GET[serch] ;
$_SESSION[hh]='';
$_SESSION[eu2]='0';
$_SESSION[start]='0';
  $_SESSION[ser]='1';

  $_SESSION[se]=$_GET[serch];
  $_SESSION[txt]=$_GET[txt];
  //$_SESSION[txt]=$_SESSION[st];
  //echo $_SESSION[st];
  $_SESSION[fs]=$_GET[fs];
  	$search=$_SESSION[se];
	$fieldtext=$_SESSION[txt];
	$fieldselect=$_SESSION[fs];

	if($search=='equal')
	   $s="= '{$fieldtext}' ";
	if($search=='diferent')
	   $s=" !=$fieldtext ";
	if($search=='minor')
	   $s=" <$fieldtext ";
	if($search=='more')
	   $s=" >$fieldtext ";
	if($search=='minororequal')
	   $s=" <=$fieldtext";
	if($search=='moreorequal')
	   $s=" >=$fieldtext";
	if($search=='content')
	   $s=" LIKE '%$fieldtext%'";
	if($search=='notcontent')
	   $s=" NOT LIKE '%$fieldtext%'";
	   $_SESSION[fildtext]=$s;
	   //echo $_SESSION[fs];
  include_once ($_SESSION[selpage]);
  //echo $_SESSION['p'];
  $_SESSION[hh]='1';



}

if($_GET[sorting])
{

$_SESSION[ser]='0';
 $_SESSION[sf]='city';
  $_SESSION[sor]='city';
 $_SESSION[sor]=$_GET[lbl];
 //echo $_GET[so];
 $tto=$_GET[so];
 if($tto=='1')
  $_SESSION[ser]='1';

$_SESSION[sf]=$_GET[sorting];


 $_SESSION[ww]=$_GET[lbl];

  if($_GET['order'] == 'asc')
    $_SESSION[orde] = 'desc';
 else
    $_SESSION[orde] = 'asc';
  include_once ($_SESSION[selpage]);
  //include_once('paging3.php');
  //include_once('button.php');
  //$_SESSION[sort]="";

}

if($_GET[majet])
{
  $_SESSION[mjid]=$_GET[majet];
  $_SESSION[selpage]=$_GET[pg];
  include ($_SESSION[selpage]);

}

if($_GET[serpaging])
{
 $_SESSION[ro]='1';
 $_SESSION[strt]='0';
 $pge=$_GET[serpaging];
 $pge=$pge-1;
 $pge=$pge*$_SESSION[lim];
 $_SESSION[row]=$pge;
// echo $_GET[serpaging];
 include_once ($_SESSION[selpage]);
}

if($_GET['sel'])
{
//echo "SELECT concat(fname,' ',lname) as name FROM ozv WHERE lname like ('%" .$_GET['sel'] . "%') ORDER BY id";
  $suggest_query = mysql_query("SELECT concat(fname,' ',lname) as name,id FROM ozv WHERE lname like ('%" .$_GET['sel'] . "%') ORDER BY id");
  while($suggest = mysql_fetch_array($suggest_query)) {
		echo $suggest['name'] . "\n";
		}
}
if($_GET['sel1'])
{
  $suggest_query = mysql_query("SELECT *  FROM ketab WHERE name like ('%".$_GET['sel1']."%') ORDER BY id  ");
  while($suggest = mysql_fetch_array($suggest_query)) {
		echo $suggest['name'] . "\n";
		}
}
if($_GET['ajxshow'])
{
if((ord($_GET['ajxshow'])>= '49') && (ord($_GET['ajxshow'])<= '57'))
 {
   if($_GET['tbl']=='ozv')
    $suggest_query = mysql_query("SELECT concat(fname,' ',lname) as name,id FROM ozv WHERE id='" .$_GET['ajxshow'] . "'");
   elseif($_GET['tbl']=='ketab')
    $suggest_query = mysql_query("SELECT name,id FROM ketab WHERE id='" .$_GET['ajxshow'] . "'");
  $suggest = mysql_fetch_array($suggest_query);
  echo $suggest['id'].'~'.$suggest['name'];

 }
 else
 {
   if($_GET['tbl']=='ozv')
    $suggest_query = mysql_query("SELECT * FROM ozv WHERE concat(fname,' ',lname)='" .$_GET['ajxshow'] . "'");
  elseif($_GET['tbl']=='ketab')
    $suggest_query = mysql_query("SELECT * FROM ketab WHERE name='" .$_GET['ajxshow'] . "'");
 $suggest = mysql_fetch_array($suggest_query);
 echo $suggest['id'].'~'.$suggest['id'];
 }

}


?>
