Answer the question
In order to leave comments, you need to log in
Am I processing the array incorrectly?
Here's what I get when I query dpaste.com/2ZHXNXN
Here's the code dpaste.com/02SY6C0
On the second foreach pass, $val is empty. What am I doing wrong?
Answer the question
In order to leave comments, you need to log in
foreach ($ar as $val) { is an extra loop.
You get an array of $row. Here on it also it is necessary to iterate.
$i++; move it to the outer loop while
$j++ - to the loop through the array.
It's better to immediately use the associative mysqli_fetch_assoc
And in general: I don't like your while ($db = mysqli_fetch_assoc( ... ))...
PS: You can't send headers after something has been rendered on the page.
Warning: Invalid argument supplied for foreach()
This error usually occurs if there is nothing to "foreach". Check array for non-emptiness before using foreach
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question