# How to access variable inside class

**URL:** https://forum.kirupa.com/t/how-to-access-variable-inside-class/309494
**Category:** Uncategorized
**Created:** [May 17, 2010, 6:40am UTC](https://forum.kirupa.com/t/how-to-access-variable-inside-class/309494 "2010-05-17T06:40:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![utsav](https://avatars.discourse-cdn.com/v4/letter/u/e19b73/32.png) [@utsav](https://forum.kirupa.com/u/utsav)
#### Post date: [May 17, 2010, 6:40am UTC](https://forum.kirupa.com/t/how-to-access-variable-inside-class/309494/1 "2010-05-17T06:40:24Z")

</div>

i have made a class which has functions to handle database activities like add, edit, delete etc. so what i am having problem is in the select statement…  
what i want to do is execute the select query and find the num\_rows in the class along with fetching the array tht the select statement fetches… is it possible to fetch inside class and show it outside using object… lemme know if i am not clear to you… here is my code…

```php

public function selecthtml($table,$rows,$condition,$order,$limit)
    {		
		$select = "select $rows from $table where $condition";
		if($order != "" || $order != NULL)
		{
			$select .= "order by $order";
		}
		if($limit != "" || $limit != NULL)
		{
			$select .= "limit $limit";
		}
		
		$done = mysql_query($select);
		if($number = mysql_num_rows($done) >= 1)
		{
			$res = mysql_fetch_array($done);
			return true;
		}
		else
		{
			return false;
		}
	}

```

Now i want to show the values fetched by $res how do i do it?
