Thanks to everyone on here who offered me help with this.

I have managed to work out how to do it.

The code I needed was:
Code:
foreach($opt as $row) {
$optno = $row->subjectid;
}
Hope that helps someone else at some point.

Barry