Hi Lavanya
Ah. i didn't realise you were doing a join on two tables. AFAIK that means you'll need to use a generic type functiion basically to pass your own sql e.g.
get_records_sql($sql);
Try that and var_dump the result to see what structure it is in.
I'm not sure why your SQL has a group by on it? You are not trying to use any aggregate functions I think? But I may well be missing something here.
Note that that function requires you return a unique col so tentatively I'd try this:
$sql = 'SELECT c.id, c.fullname FROM mdl_reenroll r, mdl_course c WHERE r.courseid = c.id ORDER BY c.fullname'
$result = get_records_sql($sql);
But I'm no expert on Moodle & there may be a method for doing JOINS on tables. If so it'd be better to use that.
regards
Justin