is this the right way to do this mysql query
this is my table

![enter image description here][1]


I am trying to get the all the ids under a main category. this works perfect but is it the right way to do

        FROM category WHERE (lft >= '$left') AND (rgt <='$right')

****





		$cat_id =  mysql_real_escape_string($_GET['cat_id']);
		
		$res = mysql_query("SELECT lft, rgt FROM category WHERE cat_id = '$cat_id'");
		while ($category = mysql_fetch_assoc($res)) 
		   {
			   $left = $category['lft'];
			   $right = $category['rgt'];
		   }


		$res = mysql_query("SELECT cat_id, lft, rgt FROM category WHERE (lft >= '$left') AND (rgt <='$right')");`

  [1]: http://i.stack.imgur.com/JJtPD.png

is this the right way to do this mysql query
===

this is my table

![enter image description here][1]


I am trying to get the all the ids under a main category. this works perfect but is it the right way to do

        FROM category WHERE (lft >= '$left') AND (rgt <='$right')

****





		$cat_id =  mysql_real_escape_string($_GET['cat_id']);
		
		$res = mysql_query("SELECT lft, rgt FROM category WHERE cat_id = '$cat_id'");
		while ($category = mysql_fetch_assoc($res)) 
		   {
			   $left = $category['lft'];
			   $right = $category['rgt'];
		   }


		$res = mysql_query("SELECT cat_id, lft, rgt FROM category WHERE (lft >= '$left') AND (rgt <='$right')");`

  [1]: http://i.stack.imgur.com/JJtPD.png
