Muddy_Funster Posted October 3, 2011 Share Posted October 3, 2011 it looks to me that you're using the $this object in other functions as well, could we see them also? if any of them are private or protected there could be problems coming from that. Also, could you please try and be as specific as possible when reporting the issues that you are having: nothing as a term is not helpfull, and even less helpfull is saying "nothing" and then without any changes saying "i'm only getting the numbers". What exactly is on the screen, and what do you see if you view page source? Quote Link to comment https://forums.phpfreaks.com/topic/248256-drop-down-boxes/page/2/#findComment-1275182 Share on other sites More sharing options...
cerberus478 Posted October 4, 2011 Author Share Posted October 4, 2011 When I said nothing I meant nothing, I don't get any information what so ever and the numbers that I get is 327671 Quote Link to comment https://forums.phpfreaks.com/topic/248256-drop-down-boxes/page/2/#findComment-1275500 Share on other sites More sharing options...
cerberus478 Posted October 4, 2011 Author Share Posted October 4, 2011 I have found a solution to half of my problem. I can now show all the resorts in the search page, so now the problem is it doesn't give me the what I selected. I changed <?php foreach ($this->_params['list'] as $resort){ ?> to this <?php $resorts_model = new resorts_model('resorts'); $resorts = $resorts_model->get_all(); foreach ($resorts as $resort){ Quote Link to comment https://forums.phpfreaks.com/topic/248256-drop-down-boxes/page/2/#findComment-1275507 Share on other sites More sharing options...
Buddski Posted October 4, 2011 Share Posted October 4, 2011 Unless we have prior knowledge of your classes and how/if the REQUEST parameters are assigned within, it will be hard to offer assistance. Do you know how your classes are treating REQUEST parameters? Quote Link to comment https://forums.phpfreaks.com/topic/248256-drop-down-boxes/page/2/#findComment-1275510 Share on other sites More sharing options...
cerberus478 Posted October 4, 2011 Author Share Posted October 4, 2011 I don't know sorry. Quote Link to comment https://forums.phpfreaks.com/topic/248256-drop-down-boxes/page/2/#findComment-1275511 Share on other sites More sharing options...
cerberus478 Posted October 4, 2011 Author Share Posted October 4, 2011 This is my pages.controller class class pages_controller extends controller{ protected $_helpers = array('form', 'html'); protected $_observers = array('item_views', 'seo_uris'); public $model='pages'; public function home(){ $this->_params['item'] = $this->_model->get(array("name='home'"), array('has_recursion' => 0)); $featured_items_model = new featured_items_model('featured_items'); $in_str = $this->get_in_industry_string(); $featured_item_id = $this->_model->get_one("SELECT featured_item_id FROM featured_items_industries WHERE industry_id IN $in_str ORDER BY rand() LIMIT 1"); if($featured_item_id){ $this->_params['featured_item'] = $featured_items_model->get($featured_item_id); if(!empty($this->_params['featured_item']['testimonials'])){ $this->_params['featured_tesimonial'] = $this->_params['featured_item']['testimonials'][rand(0, count($this->_params['featured_item']['testimonials']) - 1)]; } } $countries_model = new countries_model('countries'); $countries = $countries_model->all_for_site($this->_params['site']['id']); if(!empty($countries)){ foreach ($countries as $country){ if(!$this->has_listings('countries', $country['id']) || empty($country['regions'])){ continue; } $regions = $country['regions']; $country['regions'] = array(); foreach($regions as $region){ if(!$this->has_listings('regions', $region['id'])){ continue; } $country['regions'][] = $region; } if(empty($country['regions'])){ continue; } $this->_params['countries'][] = $country; } } $this->_params['facilities'] = $this->_model->get_rows("SELECT * FROM resort_facilities"); $this->_params['lifestyles'] = $this->_model->get_rows("SELECT * FROM lifestyles"); //$this->_call_observers('pages_view', array('controller', 'pages', 'action', 'home')); } public function search(){ $resorts_model = new resorts_model('resorts'); $this->_params['title'] = "Resorts "; $this->_params['list'] = array(); if(is_numeric($this->_params['region_id'])){ $region = $this->_model->get_one("SELECT name FROM regions WHERE id = {$this->_params['region_id']}"); } if(is_numeric($this->_params['lifestyle_id'])){ $lifestyle = $this->_model->get_one("SELECT name FROM lifestyles WHERE id = {$this->_params['lifestyle_id']}"); } if(is_numeric($this->_params['resort_facility_id'])){ $resort_facility = $this->_model->get_one("SELECT name FROM resort_facilities WHERE id = {$this->_params['resort_facility_id']}"); } $possible_conditions = array('region_id' => "resorts.region_id = {$this->_params['region_id']}", 'lifestyle_id' => "resorts.id = lifestyles_resorts.resort_id AND lifestyles_resorts.lifestyle_id = {$this->_params['lifestyle_id']}", 'resort_facility_id' => "resorts.id = resorts_resort_facilities.resort_id AND resorts_resort_facilities.resort_facility_id = {$this->_params['resort_facility_id']}"); $combinations = array(array('region_id', 'lifestyle_id', 'resort_facility_id'), array('region_id', 'lifestyle_id'), array('region_id', 'resort_facility_id'), array('lifestyle_id', 'resort_facility_id'), array('region_id'), array('lifestyle_id'), array('resort_facility_id')); $i = 0; $in_str = $this->get_in_industry_string(); while(empty($this->_params['list']) && $i < count($combinations)){ $conditions = array(); for($j = 0; $j < count($combinations[$i]); $j++){ if(is_numeric($this->_params[$combinations[$i][$j]])){ $conditions[$combinations[$i][$j]] = $possible_conditions[$combinations[$i][$j]]; } } $resorts = $resorts_model->get_all($conditions); if(!empty($resorts)){ foreach($resorts as $resort){ if(!$this->has_listings('resorts', $resort['id'])){ continue; } $resort['lifestyles'] = $resorts_model->get_lifestyles($resort['id']); $resort['cheapest_listing'] = $resorts_model->get_cheapest_listing($resort['id'], $in_str); $this->_params['list'][] = $resort; } } $i ++; } foreach($conditions as $id_name => $condition){ $name = str_replace('_id', '', $id_name); if($name == 'region'){ $this->_params['title'] .= ' in '; }elseif(!strstr($this->_params['title'], ' with ')){ $this->_params['title'] .= ' with '; }else{ $this->_params['title'] .= ' and '; } $this->_params['title'] .= $name; p($this->_params['list']); } } public function subscribe(){ $this->_call_observers('pages_view', array('controller', 'pages', 'action', 'subscribe')); } public function advertise(){ $this->_call_observers('pages_view', array('controller', 'pages', 'action', 'advertise')); } public function admin(){ $sql = "SELECT DISTINCT companies.id, companies.name FROM users, companies, banners WHERE companies.user_id = users.id AND banners.company_id = companies.id AND users.enabled = 1 ORDER BY companies.name"; $this->_params['companies'] = $this->_model->get_rows($sql); } public function statistics(){ $this->_layout = 'statistics_print'; $table = register('stat_type'); $date_from = register('date_from'); $date_to = register('date_to'); if($date_from){ $components = explode('/', $date_from); $date_from = mktime(0,0,0, $components[1], $components[0], $components[2]); } if($date_to){ $components = explode('/', $date_to); $date_to = mktime(0,0,0, $components[1], $components[0] + 1, $components[2]); } $this->_view = $table.'_views'; switch($table){ case 'pages': $sql = "SELECT SUM(pages_views.count) as count, pages_views.controller, pages_views.action, sites.name FROM pages_views, sites WHERE pages_views.site_id = sites.id"; if($date_from){ $sql .= " AND pages_views.hour_start >= $date_from"; } if($date_to){ $sql .= " AND pages_views.hour_start <= $date_to"; } $sql .= " GROUP BY pages_views.controller, pages_views.action, sites.id ORDER BY count DESC"; break; case 'industries': $sql = "SELECT SUM(industries_views.count) as count, industries.name as industry_name, sites.name as site_name FROM industries_views, industries, sites WHERE industries_views.site_id = sites.id AND industries.id = industries_views.industry_id"; if($date_from){ $sql .= " AND industries_views.hour_start >= $date_from"; } if($date_to){ $sql .= " AND industries_views.hour_start <= $date_to"; } $sql .= " GROUP BY industries.name, sites.id ORDER BY count DESC"; break; case 'listings': $sql = "SELECT SUM(listings_views.count) as count, listings_views.profile, listings.name as listing_name, listing_types.name as listing_type, resorts.name as resort_name, sites.name as site_name FROM listings_views, listings, listing_types, resorts, sites WHERE listings_views.listing_id = listings.id AND listings_views.site_id = sites.id AND listings.resort_id = resorts.id AND listings.listing_type_id = listing_types.id"; if($date_from){ $sql .= " AND listings_views.hour_start >= $date_from"; } if($date_to){ $sql .= " AND listings_views.hour_start <= $date_to"; } $sql .= " GROUP BY listings.name, sites.id ORDER BY count DESC"; break; case 'resorts': $sql = "SELECT SUM(resorts_views.count) as count, resorts.name as resort_name, sites.name as site_name FROM resorts_views, resorts, sites WHERE resorts_views.resort_id = resorts.id AND resorts_views.site_id = sites.id"; if($date_from){ $sql .= " AND resorts_views.hour_start >= $date_from"; } if($date_to){ $sql .= " AND resorts_views.hour_start <= $date_to"; } $sql .= " GROUP BY resorts.name, sites.id ORDER BY count DESC"; break; case 'companies': $sql = "SELECT SUM(companies_views.count) as count, companies.name as company_name, sites.name as site_name FROM companies_views, companies, sites WHERE companies_views.company_id = companies.id AND companies_views.site_id = sites.id"; if($date_from){ $sql .= " AND companies_views.hour_start >= $date_from"; } if($date_to){ $sql .= " AND companies_views.hour_start <= $date_to"; } $sql .= " GROUP BY companies.name, sites.id ORDER BY count DESC"; break; case 'news_items': $sql = "SELECT SUM(news_items_views.count) as count, news_items.name as news_item_name, sites.name as site_name FROM news_items_views, news_items, sites WHERE news_items_views.news_item_id = news_items.id AND news_items_views.site_id = sites.id"; if($date_from){ $sql .= " AND news_items_views.hour_start >= $date_from"; } if($date_to){ $sql .= " AND news_items_views.hour_start <= $date_to"; } $sql .= " GROUP BY news_items.name, sites.id ORDER BY count DESC"; break; case 'banners': $sql = "SELECT name FROM companies WHERE id = {$this->_params['company_id']}"; $this->_params['company'] = $this->_model->get_one($sql); $sql = "SELECT SUM(banner_views.views) as banner_views, banners.id, banners.position, companies.name as company_name, sites.name as site_name, sites.id as site_id FROM banner_views, banners, companies, sites WHERE banner_views.banner_id = banners.id AND banners.company_id = companies.id AND sites.id = banner_views.site_id AND companies.id = {$this->_params['company_id']}"; if($date_from){ $sql .= " AND banner_views.created >= $date_from"; } if($date_to){ $sql .= " AND banner_views.created <= $date_to"; } $sql .= " GROUP BY banners.id, sites.id ORDER BY banner_views DESC"; $banners = $this->_model->get_rows($sql); if(!empty($banners)){ foreach($banners as $banner){ $sql = "SELECT SUM(clicks) FROM banner_clicks WHERE banner_id = {$banner['id']} AND site_id = {$banner['site_id']}"; if($date_from){ $sql .= " AND created >= $date_from"; } if($date_to){ $sql .= " AND created <= $date_to"; } $banner['clicks'] = $this->_model->get_one($sql); $this->_params['list'][] = $banner; } } break; } if(empty($this->_params['list'])){ $this->_params['list'] = $this->_model->get_rows($sql); } } public function view($id){ $this->_params['item'] = $this->_model->get($id); if($this->_params['item']['site_id'] != $this->_params['site']['id']){ $this->_page->set_metatag('name', 'Robots', 'noindex,follow'); } } public function listing_comparison($sort = false){ $this->_params['item'] = $this->_model->get(19); $listings_model = new listings_model('listings'); $in_str = $this->get_in_industry_string(); $conditions = array("users.enabled = '1'", "listings.enabled = '1'", "resorts.enabled = '1'", "(listings.sale_listing = '1' OR listings.resale_listing = '1')", "listing_types.industry_id IN $in_str"); $items = $listings_model->get_all($conditions); $return = array(); switch ($sort){ case 'province': foreach($items as $item){ if(empty($item['resorts.region_id'])){ continue; } $sql = "SELECT regions.name FROM regions WHERE id = {$item['resorts.region_id']}"; $item['regions.name'] = $this->_model->get_one($sql); $return[$item['regions.name']][] = $item; } ksort($return); break; case 'resort': foreach($items as $item){ $return[$item['resorts.name']][] = $item; } ksort($return); break; case 'category': foreach($items as $item){ $sql = "SELECT name FROM industries WHERE id = {$item['listing_types.industry_id']}"; $item['industries.name'] = $this->_model->get_one($sql); $return[$item['industries.name']][] = $item; } ksort($return); break; default: $non_numerics = array(); $numerics = array(); foreach($items as $item){ if($item['sale_listing']){ $price = trim($item['sale_profiles.price']); }else{ $price = trim($item['resale_profiles.price']); } $price = str_replace(' ', '', $price); $price = str_replace('.00', '', $price); if(is_numeric($price) || (strpos($price, 'R') == 0 && $price != 'Request')){ $price = str_replace('R', '', $price); $key = (int)str_replace(',', '', $price); $return[$key][] = $item; }else{ $non_numerics[$price][] = $item; } } krsort($return); if(!empty($non_numerics)){ ksort($non_numerics); $return = $non_numerics + $return; } break; } foreach($return as $key => $items){ foreach($items as $item){ if(empty($item['resorts.region_id'])){ continue; } if(empty($item['regions.name'])){ $sql = "SELECT regions.name FROM regions WHERE id = {$item['resorts.region_id']}"; $item['regions.name'] = $this->_model->get_one($sql); } $sql = "SELECT image_path FROM listing_images WHERE listing_id = {$item['id']}"; $item['image_path'] = $this->_model->get_one($sql); if(empty($item['industries.name'])){ $sql = "SELECT name FROM industries WHERE id = {$item['listing_types.industry_id']}"; $item['industries.name'] = $this->_model->get_one($sql); } $item = $listings_model->get_type_def($item); $this->_params['list'][$key][] = $item; } } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/248256-drop-down-boxes/page/2/#findComment-1275521 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.