Welcome Guest, Not a member yet? Register   Sign In
Outputting results from Array?
#1

[eluser]invision[/eluser]
Hi,

I'm a little stuck. I would love some help with this.

I want to output the results of a SQL Query into a View.

How do I do this?


model
Code:
function get_entries($country = FALSE, $city = FALSE, $category = FALSE) {

    $this->db->select('entry.*, city.title as city_title, country.iso3 as country_title, category.title as category_title');
    $this->db->from('entry');
    $this->db->join('category', 'entry.category_id = category.id');
    $this->db->join('city', 'entry.city = city.id');
    $this->db->join('country', 'city.country = country.iso3');
    if($country !== FALSE) {
      $this->db->where('country.iso3', $country);
    }
    if($city!== FALSE) {
      $this->db->where('city.title', $city);
    }
    if($category!== FALSE) {
      $this->db->where('entry.aslug', $category);
    }
    $result = $this->db->get();
    if($result->num_rows() > 0) {
      return $result->result_array();
    } else {
      return FALSE;
    }
  }

controller
Code:
if (!empty($param_3)) {
      $data['title'] = $param_3;
      $data['body'] = 'Info about Accommodation';  
        $data['entries'] = $this->Mains->get_entries($param_1, $param_2, $param_3);
        $data['entries2'] = $this->Mains->get_all_cities();
        $data['main'] = 'public_entry';  
     }

view
Code:
<h2>&lt;?php echo $entries['atitle']; ?&gt;</h2>

I know for certain that my SQL Query is working.

Can anyone explain what I am doing wrong?



Many thanks for your time and help.


Messages In This Thread
Outputting results from Array? - by El Forum - 01-01-2011, 08:20 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:01 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:04 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:22 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:26 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:29 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:33 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:38 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:40 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:43 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:46 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:54 AM
Outputting results from Array? - by El Forum - 01-01-2011, 09:57 AM
Outputting results from Array? - by El Forum - 01-01-2011, 10:01 AM
Outputting results from Array? - by El Forum - 01-01-2011, 10:03 AM
Outputting results from Array? - by El Forum - 01-01-2011, 10:04 AM
Outputting results from Array? - by El Forum - 01-01-2011, 10:05 AM
Outputting results from Array? - by El Forum - 01-01-2011, 10:06 AM
Outputting results from Array? - by El Forum - 01-01-2011, 10:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB