this is the function in class that i use
public function content($search) {
$this->dbconnection();
$search = mysql_real_escape_string($search);
$q= mysql_query("SELECT title FROM xx WHERE title LIKE '%$search%'");
$s = mysql_fetch_array($q);
foreach ($s as $key => $val) {
$$key = $val;
}
}
and on index.php file
$cl= new Class;
$test = $cl->content('cloud');
and question is
how can i echo the variable which i set inside foreach loop?
$test->title; < this is not working for sure, but this explains the thing that i am trying to do.
Return the array as an object:
Then in your code:
Alternatively, you could fetch the row as an object by using mysql_fetch_object