Note that there are some explanatory texts on larger screens.

plurals
  1. POSearch with two input fields in codeigniter
    text
    copied!<p>I have a searchform to search factories in my database. my factories table has a field called 'postcode' now when you visit the site for the first time you have to type in your postcode. this will be saved in a cookie so you don't have to change it again.</p> <p>Now i want to search for factories using a searchterm and the cookie 'postcode'</p> <p>here is my searchform <a href="http://kees.een-site-bouwen.nl/" rel="nofollow noreferrer">http://kees.een-site-bouwen.nl/</a></p> <p>So something like this:</p> <pre><code>&lt;form action="home/searchresults" method="post"&gt; &lt;input type="search" placeholder="search..." name="search"&gt; &lt;input type="search" value="&lt;?= $this-&gt;input-&gt;cookie('postcode')?&gt;"&gt; &lt;/form&gt; </code></pre> <p>and in my controller something like:</p> <pre><code>$match = $this-&gt;input-&gt;post('search'); $match2 = $this-&gt;input-&gt;cookie('postcode'); $data['query'] = $this-&gt;bedrijven_model-&gt;get_search($match, $match2); $this-&gt;load-&gt;view('views/header'); $this-&gt;load-&gt;view('views/searchresults', $data); $this-&gt;load-&gt;view('views/footer'); </code></pre> <p>in my model i have:</p> <pre><code>function get_search($match) { $this-&gt;db-&gt;like('Bedrijfsnaam', $match); $this-&gt;db-&gt;or_like('Postcode', $match); $this-&gt;db-&gt;or_like('Plaats', $match); $this-&gt;db-&gt;or_like('Telefoonnummer', $match); $this-&gt;db-&gt;or_like('Email', $match); $this-&gt;db-&gt;or_like('Website', $match); $this-&gt;db-&gt;or_like('Profiel', $match); $this-&gt;db-&gt;or_like('Adres', $match); $this-&gt;db-&gt;or_like('Categorie', $match); $this-&gt;db-&gt;join('bedrijven', 'bedrijfcategorieen.idbedrijven = bedrijven.idbedrijven'); $this-&gt;db-&gt;join('categorieen', 'bedrijfcategorieen.idcategorieen = categorieen.idcategorieen'); $this-&gt;db-&gt;group_by('bedrijfcategorieen.idbedrijven', 'bedrijfcategorieen.idcategorieen'); $query = $this-&gt;db-&gt;get('bedrijfcategorieen'); return $query-&gt;result(); } </code></pre> <p>But this does not work. i asked a similar question here: <a href="https://stackoverflow.com/questions/16011313/prevent-overriding-queries-in-controller-function-codeigniter">Prevent overriding queries in controller function - codeigniter</a></p> <p>but no answer that worked for me.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload