I think I know why my example didnt work either: the loop called the member function on each iteration, hence a new resource was generated every time, so the loop never exits.
I would like to know: what is an option?
Try this:
$pollId = 18;
$query = mysql_query("SELECT OptionName FROM poll_options WHERE PollID='$pollId'");
while ($row = mysql_fetch_assoc($query)) {
echo $row['OptionName'];
}
If it works, then try:
function getOption($pollId) {
$query = mysql_query("SELECT OptionName FROM poll_options WHERE PollID='$pollId'");
$result = array();
while ($row = mysql_fetch_assoc($query)) {
$result[] = $row['OptionName'];
}
return $result;
}
upon which you would use:
$result = $poll->getOption(18);
foreach ($result as $option) {
echo $option;
}
barand's method might work, but the problem is that we dont know how your poll is organised, so we are second-guessing what you want.