PHP Array issue - not looping through foreach
<p>Thanks everyone, question answered!  If anyone is interested, the updated function is as follows, all other code remains the same:</p>

<pre><code>function fetch_questions($page) {
global $link;
$proc = mysqli_prepare($link, "SELECT * FROM tquestions_cwh WHERE page = ?");
mysqli_stmt_bind_param($proc, "i", $page);
mysqli_stmt_execute($proc);


$rowq = array();
stmt_bind_assoc($proc, $rowq);

// loop through all result rows
//  while ($proc-&gt;fetch()) {
    //  print_r($rowq);
//      $rows[]=$rowq;
//  }

while ($proc-&gt;fetch())
{
    foreach($rowq as $key=&gt;$value )
    {
        $row_tmb[ $key ] = $value;
    } 
    $rows[] = $row_tmb; 
}

mysqli_stmt_close($proc);
mysqli_clean_connection($link);
return($rows);
</code></pre>

<p>} </p>

<p>Ok,</p>

<p>Here is the code:</p>

<pre><code>function fetch_questions($page) {
    global $link;
    $proc = mysqli_prepare($link, "SELECT * FROM tquestions_cwh WHERE page = ?");
    mysqli_stmt_bind_param($proc, "i", $page);
    mysqli_stmt_execute($proc);


    $rows = array();
    stmt_bind_assoc($proc, $rowq);

    // loop through all result rows
    while ($proc-&gt;fetch()) {
        //  print_r($rowq);
        $rows[]=$rowq;
    }

    mysqli_stmt_close($proc);
    mysqli_clean_connection($link);
    return($rows);
}
</code></pre>

<p>I then add this to a php variable, like so:</p>

<pre><code>$qs = fetch_questions($page);
</code></pre>

<p>I then loop through is, like so:</p>

<pre><code>foreach($qs as $value){
                echo "&lt;tr&gt;".$value['qnum']." is the questions number and the question text is ".$value['qtext'].". The page and q values are ".$value['page']." and ".$value['questions']." respectively.&lt;/tr&gt;";
</code></pre>

<p>The output, however is this:</p>

<pre><code>8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.
</code></pre>

<p>Which is not what I want, for information purposes, the array using the print function looks like this:</p>

<pre><code>Array
    (
        [0] =&gt; Array
            (
                [questions] =&gt; q8
                [qnum] =&gt; 8
                [qtext] =&gt; I know how what I do fits into my team's objectives
                [page] =&gt; 1
            )

        [1] =&gt; Array
            (
                [questions] =&gt; q8
                [qnum] =&gt; 8
                [qtext] =&gt; I know how what I do fits into my team's objectives
                [page] =&gt; 1
            )

        [2] =&gt; Array
            (
                [questions] =&gt; q8
                [qnum] =&gt; 8
                [qtext] =&gt; I know how what I do fits into my team's objectives
                [page] =&gt; 1
            )

        [3] =&gt; Array
            (
                [questions] =&gt; q8
                [qnum] =&gt; 8
                [qtext] =&gt; I know how what I do fits into my team's objectives
                [page] =&gt; 1
            )

        [4] =&gt; Array
            (
                [questions] =&gt; q8
                [qnum] =&gt; 8
                [qtext] =&gt; I know how what I do fits into my team's objectives
                [page] =&gt; 1
            )

        [5] =&gt; Array
            (
                [questions] =&gt; q8
                [qnum] =&gt; 8
                [qtext] =&gt; I know how what I do fits into my team's objectives
                [page] =&gt; 1
            )

        [6] =&gt; Array
            (
                [questions] =&gt; q8
                [qnum] =&gt; 8
                [qtext] =&gt; I know how what I do fits into my team's objectives
                [page] =&gt; 1
            )

        [7] =&gt; Array
            (
                [questions] =&gt; q8
                [qnum] =&gt; 8
                [qtext] =&gt; I know how what I do fits into my team's objectives
                [page] =&gt; 1
            )

    )
</code></pre>

<p>Clearly it's not looping through and displaying each row as it should...any advice?</p>

<p>Homer.</p>
