Welcome Guest, Not a member yet? Register   Sign In
Search Form
#1

[eluser]maddtechwf[/eluser]
I've got the basic form setup on my view and then I have a Model and Controller setup also. But my search is not working. Can anyone help point me in the right direction??? I have the form helper autoloaded.

View
Code:
<?php echo form_open('map/lookup'); ?>
            <input type="text" name="search-item" />
            <button class="searchbutton" tabindex="3" value="SEARCH"></button>
        &lt;?php echo form_close(); ?&gt;

Controller
Code:
public function lookup()
    {
        $search_value = $this->input->post('search-item', TRUE);
      
        $results = $this->map_model->search($search_value);
        
        if ( $results->num_rows() > 0 )
        {
            foreach ( $results->result() as $result )
            {
                $marker = array();
                $marker['position'] = $result->Lat.','.$result->Long;
                $this->googlemaps->add_marker($marker);
            }
        }
    }

Model
Code:
function search($term)
        {
            $return = array();
            
            //DB Connection
            $this->db->select("Lat,Long,Name,Address1,City,State,Zip");
            $this->db->from("Points");
            $this->db->like('Name', $term);
            // $this->db->like('Tags', $term);
            $search_results = $query = $this->db->get();
            
            if ( $search_results->num_rows() > 0 )
            {
                foreach ( $search_results->result() as $result )
                {
                    array_push($return, $result);
                }
            }
            
            return $return;
        }
#2

[eluser]jairoh_[/eluser]
try print_r( $results ), if empty then there's something wrong w/ the query.




Theme © iAndrew 2016 - Forum software by © MyBB