My PHP class function looks something like as when fetching data from database table:
class my {
public $a;
public function myFunc(){
$query = mysql_query("select name,loc,info from stores");
while ($row = mysql_fetch_array($query)) {
extract($row);
echo $this->a;
}
}
}
I want that it should print the result of that rows of table which are called when creating object of the class and calling class method as:
$class = new my();
$class->a = '<h1>$name</h1>';
$class->a .= '<p>$loc</p>';
$class->myFunc();
But it did't gives proper result and print as:
$name
$loc
$name
$loc
$name
$loc
...
I want it should print the values of these variable which are actually rows of table and result should be something looking like as:
london store
london near the big mall, england
PK world wide store
F-5 street near the new G-T road london
...
How it can be possible?
Thank You.