clearSearch (); } $object = new obj; $sql = "select * from object as obj inner join type as t on (t.typeId = obj.obtypeid) inner join state as st on (st.stateId = obj.obstateid) where obj.obConfirm = '1' AND obj.obConfirm = '1' AND obj.obPromoDateEnd > NOW() and obj.obPromo = 1 ORDER by obj.obId DESC LIMIT ".$cfg['objectIndexPromo'].""; $q = $mysql -> q( $sql ); $smarty -> assign('nump', $mysql -> num( $sql )); $promo = array(); $count = 0; while ( $db = mysql_fetch_array( $q ) ) { $promo[$count] = $db; $sql2 = "SELECT photoUrl, frstPhoto FROM photos WHERE photoObjectId = '".$db['obId']."' and frstPhoto = 1"; $q2 = $mysql -> q( $sql2 ); $db2 = mysql_fetch_array( $q2 ); $promo[$count]['photo'] = $db2[0]; $count++; } $smarty -> assign('promo', $promo); if ( isset( $_POST['getSearch'] ) ) { $_SESSION['txt'] = html( $_POST['txt'] ); $_SESSION['city'] = html( $_POST['city'] ); $_SESSION['state'] = html( $_POST['state'] ); $_SESSION['type'] = html( $_POST['type'] ); $_SESSION['priceOn'] = html( $_POST['priceOn'] ); $_SESSION['priceOff'] = html( $_POST['priceOff'] ); } $smarty -> assign('txt', $_SESSION['txt']); $smarty -> assign('city', $_SESSION['city']); $smarty -> assign('state', $_SESSION['state']); $smarty -> assign('type', $_SESSION['type']); $smarty -> assign('priceOn', $_SESSION['priceOn']); $smarty -> assign('priceOff', $_SESSION['priceOff']); $smarty -> assign('showType', $object -> showType( $mysql )); $smarty -> assign('showState', $object -> showState( $mysql )); $link = 'szukaj,{^link}.html'; $sql = "SELECT a.*, b.*, c.* FROM object AS a, type AS b, state AS c WHERE a.obTypeId = b.typeId AND a.obStateId = c.stateId AND a.obConfirm = '1' AND a.obDateEnd > NOW()"; if ( !empty( $_SESSION['txt'] ) && $_SESSION['txt'] !== 'szukana fraza' ) { $sql .= " AND a.obName LIKE '%".$_SESSION['txt']."%'"; } if ( !empty( $_SESSION['city'] ) && $_SESSION['city'] !== 'miejscowość' ) { $sql .= " AND a.obCity LIKE '%".$_SESSION['city']."%'"; } if ( !empty( $_SESSION['state'] ) ) { $sql .= " AND a.obStateId = '".$_SESSION['state']."'"; } if ( !empty( $_SESSION['type'] ) ) { $sql .= " AND a.obTypeId = '".$_SESSION['type']."'"; } if ( !empty( $_SESSION['priceOn'] ) && $_SESSION['priceOn'] !== 'cena od' && !empty( $_SESSION['priceOff'] ) && $_SESSION['priceOff'] !== 'cena do' ) { $sql .= " AND a.obPriceOff BETWEEN '".$_SESSION['priceOn']."' AND '".$_SESSION['priceOff']."'"; } //// if ( $_GET['act'] == 'last' ) { $sql .= " AND a.obLastMinute = '1'"; $link = 'szukaj,{^link},last-minute.html'; } if ( $_GET['act'] == 'promowane' ) { $sql .= " AND a.obPromo = '1'"; $link = 'szukaj,{^link},promowane.html'; } if ( $_GET['act'] == 'morze' ) { $sql .= " AND a.obStateId = '11'"; $link = 'szukaj,{^link},morze.html'; } if ( $_GET['act'] == 'jezioro' ) { $sql .= " AND a.obStateId = '14'"; $link = 'szukaj,{^link},jezioro.html'; } if ( $_GET['act'] == 'gory' ) { $sql .= " AND a.obStateId = '9'"; $link = 'szukaj,{^link},gory.html'; } if ( $_GET['act'] == 'state' & isset( $_GET['id'] ) ) { $sql .= " AND a.obStateId = '".$_GET['id']."'"; $link = 'szukaj,state,' . $_GET['id'] . ',{^link},'. $_GET['n'] . '.html'; } $n = $cfg['searchOfPage']; $smarty -> assign('n', $n); $q = $mysql -> q( $sql ); $num = $mysql -> num( $sql ); $smarty -> assign('num', $num); $p = new Pager('kat', $num, $n, '100'); $p -> setVar("html_link", "{^name}\n"); $p -> Render(); $start = $p -> startRecord(); $sql .= " ORDER by a.obId DESC LIMIT $start, $n"; //echo $sql; $q = $mysql -> q( $sql ); $index = array(); $count = 0; while ( $db = mysql_fetch_array( $q ) ) { $index[$count] = $db; $sql2 = "SELECT photoUrl FROM photos WHERE photoObjectId = '".$db['obId']."' ORDER by photoId ASC LIMIT 1"; $q2 = $mysql -> q( $sql2 ); $db2 = mysql_fetch_array( $q2 ); $index[$count]['photo'] = $db2[0]; $count++; } //print_r($index); $smarty -> assign('rand', rand(1,5)); $smarty -> assign('len', $count); $smarty -> assign('index', $index); $str = $p -> getVar("html_out"); $smarty->assign('str', $str); $smarty -> assign('title', 'Wyniki wyszukiwania'); $smarty -> display('szukaj.tpl'); ?>