How do I search with php sessions using the native_session library in codeigniter -


i found can't use phpsessions straight away in codeigniter i've downloaded native_sessions lib codeigniter.

i have searchquery searching postal codes in database using online postalcode database api. store postalcodes api in session , search postal codes in factory table have row postcode every factory.

so factory table looks this:

factories --------- factoryid factoryname adress postcode country ... ... ... 

my searchquery postcode looks this:

    if (!isset($_cookie['cookie'])) {          $query = "select * (`bedrijfcategorieen`)          join `bedrijven` on `bedrijfcategorieen`.`idbedrijven` = `bedrijven`.`idbedrijven`          join `categorieen` on `bedrijfcategorieen`.`idcategorieen` = `categorieen`.`idcategorieen`          (`bedrijfsnaam` '%".$this->input->post('search')."%'          or `plaats` '%".$this->input->post('search')."%'          or `telefoonnummer` '%".$this->input->post('search')."%'          or `email` '%".$this->input->post('search')."%'          or `website` '%".$this->input->post('search')."%'          or `profiel` '%".$this->input->post('search')."%'          or `adres` '%".$this->input->post('search')."%'          or `categorie` '%".$this->input->post('search')."%')  

and line searching postcode:

        , (postcode '%". $_session['postcodes'] ."%') 

this not work think doing wrong. note session called postcodes shown above.

        group `categorie`, `bedrijfcategorieen`.`idbedrijven`";         $query = $this->db->query($query);          $result = $query->result_array();          return $result; 

code setting session. form:

javascript form: (using: http://www.d-centralize.nl/pro6pp/

    function send_data_to_server(output)     {         var post_code=$('.postcode').val();         var url = 'http://kees.een-site-bouwen.nl/script.php?output='+output+'&post_code='+post_code;          $.ajax({             url : url,             success : function (data)             {             }         });     }; 

script.php data sent to:

<?php   echo '<pre>';      session_start();       $new_post_code=$_get['post_code'];         if($new_post_code!='' && $new_post_code!=0){         if(!isset($_session['searched_post_code']) ||          empty($_session['searched_post_code'])){          $_session['searched_post_code']=$new_post_code;           }elseif($_session['searched_post_code']!=$new_post_code){           $_session['searched_post_code']=$new_post_code;           unset($_session['postcodes']);          }         }      $output=$_get['output'];      $_session['postcodes'][]=$output;      echo $output;      print_r($_session); echo '</pre>';  ?> 

you have error in code. address issue facing is....

i found problem don't know how fix that. problem is searches 'postcode' '%' .array => [0] => 9101 [1] 9102... etc. way not working. found can use in_array() in normal php. how use in sql.

as have said in comment above.

i assuming $_session['postcode'] array 2 elements 9101 , 9102.

script.php

$string = implode($_session['postcode'], '|'); 

in sql query file

and (postcode '%". $_session['postcodes'] ."%') 

change to,

and (postcode regexp '$string') 

it'l give desired result.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -