I want to item\'s subcatory selected when editing category:
You need to use the global keyword inside the function:
global
function sQuery() { global $r['id']; global $subcat; if ($r['id'] == $subcat) { $t = "selected"; } else { $t = ""; } return $t; }