if something doesnt work in a function this is mostly because the variables from outside the function are not accessible in the function (they arent global)
example:
function getdata() {
$query = mysql_query("SELECT * FROM ".$table);
$result = mysql_fetch_array($query);
return $result['fieldname'];
}
$table = 'tablename';
$value = getdata();
this does not work
you need to make the $table global, the following makes it work:
function getdata() {
global $table;
$query = mysql_query("SELECT * FROM ".$table);
$result = mysql_fetch_array($query);
return $result['fieldname'];
}
$table = 'tablename';
$value = getdata();