When asking about code, always post a
minimal test case, the smallest amount of code that illustrates the behavior you're writing about. In this case, you would need to show how
$results is set and include the
foreach loop's closing brace. This makes your question easier to understand, both for others and yourself. Sometimes the solution becomes obvious upon creating the minimal test case. Remember, we can only answer questions about the code you post. If it's incomplete, we'll waste time going over errors in the posted code that don't exist in your live code.
The error message means
$results isn't
traversable. If
$results is the result of an SQL query, you can use a while loop:
PHP:
while ($result = $results->fetch()) {
...
}
or you can implement the
Iterator interface and create an
SQL result iterator.