Send php variable to a class and run mysql query with Smarty -


i send php variable class runs mysql query. typical search via html form. have use smarty.

how can pass variable "$minta" sql query , how result array php display?

the smarty tpl file ok (lista_keres.tpl ingatlank variable).

thank in advance.

tuwanbi

the php:

if (isset($_post['keresoszo'])){    include_once "classes/ingatlan.class.php";   include_once "classes/main.class.php";   include_once "classes/felhasznalo.class.php";    $ingatlan = new ingatlan();   $felhasznalo = new felhasznalo();   $minta = $_post['keresoszo'];    $kereses = new main();   $kereses->getkeresingatlan($minta);          $smarty->assign("kapcsolattartok", $ingatlan->getkapcsolattartok());         $smarty->assign("ingatlank", $main->getkeresingatlan());         $smarty->assign("include_file", lista_keres);   echo $minta; 

}

the class:

<?php  class main{ private $keresoszo; ... public function getkeresingatlan($minta){      $this->keresoszo=$minta;      $ret = array();     $sql="select id table id '% ".$keresoszo." %'";     $ret = $this->db->getarray($sql);     return $ret; }  } ?> 

declaring private $keresoszo; becomes class object , can accessible $this->keresoszo in sql query have assigned value object haven't used

<?php  class main{ private $keresoszo; ... public function getkeresingatlan($minta){      $this->keresoszo=$minta;      $ret = array();     $sql="select id table id '% ".$this->keresoszo." %'";     $ret = $this->db->getarray($sql);     return $ret; }  } ?> 

here how can results

  $kereses = new main();   $results_set=$kereses->getkeresingatlan($minta);   var_dump($results_set);// testing          $smarty->assign("my_results_set", $results_set); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -