Welcome Guest, Not a member yet? Register   Sign In
weird characters in the url
#12

[eluser]osci[/eluser]
My example is not using a url like
Code:
http://test.loc/welcome/index/search_by_name=Doe+John
but as
Code:
http://test.loc/welcome/index/Doe

i guess this has to do with
Code:
$config['uri_protocol'] = "AUTO";
any info welcome here

The controller (News as seen in site_url below)
Code:
function index($q='-', $offset = 0)
{
   $maxrec = 10;
   $this->load->model('news_model');
   $this->load->library('pagination');

   $config['base_url'] = site_url("news/index/$q");
   $config['total_rows'] = $this->news_model->count_news_q($q);
   $config['uri_segment'] = 4;
   $config['per_page'] = $maxrec;
   $config['num_links'] = 5;

   $render['records'] = $this->news_model->get_pager_records($maxrec,$offset,$q);
   $render['norecords'] = 'No records';
   $this->load->view('page', $render);
}

The model
Code:
function get_pager_records_q($max,$start,$q)
{
   if ($q !=='-'){
      $query = $this->db->from('t_news')->like('title',$q)->limit($max,$start)->get();
   } else {
      $query = $this->db->from('t_news')->limit($max,$start)->get();
   }

   if ($query->num_rows > 0)
   {
      return $query->result();
   } else {
      return false;
   }
}

function count_news_q($q) {
   if ($q!=='-'){
      return $this->db->from('t_news')->like('title',$q)->get()->num_rows();
   } else {
      return $this->db->get('t_news')->num_rows();
   }
}

The view
Code:
&lt;?php if (isset($records) & ($records <> NULL)) { ?&gt;

<table>
<thead><tr><th>Title</th></tr></thead>
<tbody>
&lt;?php foreach($records as $row) : ?&gt;
   <tr><td>
   &lt;?php echo $row->title; ?&gt;
   </td></tr>
&lt;?php endforeach; ?&gt;
</tbody>
</table>
&lt;?php
      echo $this->pagination->create_links();
  } else {
     echo $norecords;
  }
?&gt;

I have to use $q='-' as letting $q='' would produce url with double slashes in this code.


Messages In This Thread
weird characters in the url - by El Forum - 04-10-2011, 04:35 AM
weird characters in the url - by El Forum - 04-10-2011, 05:04 AM
weird characters in the url - by El Forum - 04-10-2011, 05:05 AM
weird characters in the url - by El Forum - 04-10-2011, 06:23 AM
weird characters in the url - by El Forum - 04-10-2011, 06:35 AM
weird characters in the url - by El Forum - 04-10-2011, 06:52 AM
weird characters in the url - by El Forum - 04-10-2011, 07:43 AM
weird characters in the url - by El Forum - 04-10-2011, 08:20 AM
weird characters in the url - by El Forum - 04-10-2011, 09:01 AM
weird characters in the url - by El Forum - 04-10-2011, 09:14 AM
weird characters in the url - by El Forum - 04-10-2011, 09:25 AM
weird characters in the url - by El Forum - 04-10-2011, 09:30 AM
weird characters in the url - by El Forum - 04-10-2011, 09:33 AM
weird characters in the url - by El Forum - 04-10-2011, 09:38 AM
weird characters in the url - by El Forum - 04-10-2011, 09:52 AM
weird characters in the url - by El Forum - 04-10-2011, 10:00 AM
weird characters in the url - by El Forum - 04-10-2011, 10:12 AM
weird characters in the url - by El Forum - 04-10-2011, 10:20 AM
weird characters in the url - by El Forum - 04-10-2011, 10:26 AM
weird characters in the url - by El Forum - 04-10-2011, 10:45 AM
weird characters in the url - by El Forum - 04-10-2011, 11:17 AM
weird characters in the url - by El Forum - 04-10-2011, 12:17 PM
weird characters in the url - by El Forum - 04-10-2011, 12:42 PM
weird characters in the url - by El Forum - 04-11-2011, 02:49 AM
weird characters in the url - by El Forum - 04-11-2011, 03:56 AM
weird characters in the url - by El Forum - 04-11-2011, 04:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB