php- foreach statement duplicating results
I have a while and foreach loop that I want to use to print all of my results from a MySQL query.  Below is my code for the while statement and the foreach statements. 

WHILE:

    while ($row_questions = mysql_fetch_array($result_questions)) {
     
     $step_number[]      = $row_questions['step_number'];

     if ($row_questions['step_number_sub'] != 0) {
       $step_number_sub[]  = $row_questions['step_number_sub'];
     } else {
       $step_number_sub[]  = "0";
     };

     if ($row_questions['step_required'] != 0) {
       $step_required[]  = "*";
     } else {
       $step_required[]  = "";
     };

     $step_description[] = $row_questions['step_description'];
     $step_outcome[]     = $row_questions['step_outcome'];
     $step_equipment[]   = $row_questions['step_equipment'];
     $test_changes[]     = $row_questions['test_changes'];
  };
  ?>

and my FOREACH:

    <?php

    foreach ($step_number as $i => $step){
        $even_odd = ( '-odd' != $even_odd ) ? '-odd' : '';
        echo '<section class="zebra'.$even_odd.'">';
        echo '<div class="span-2 number"><strong>'.$step_number[$i].'</strong></div>';
        echo '<div class="span-20 description">'.$step_description[$i].'</div>';
        echo '<div class="span-2">'.$step_required[$i].'</div>';
        if ($step_outcome[$i] != null) {
          echo '<div class="span-22 outcome"><strong>Desired Outcome</strong><br>'.$step_outcome[$i].'</div>';
        }
        echo '<div class="clear"></div>';
        echo '<article class="results">';
        echo '<div class="span-10">Did this step match the desired outcome?</div>';
        echo '<div class="span-10">Notes:</div>';
        echo '<div class="span-10">
              <select name="question_'.$step[$i].'" id="question_'.$step[$i].'" required aria-required="true">
              <option name="pass" value="Pass">Yes, this step was completed successfully</option>
              <option name="fail" value="Fail">No, this step failed to complete. See notes below</option>
              </select>
              </div>';
        echo '<div class="span-10"><textarea name="question_'.$step[$i].'" id="question_'.$step[$i].'" class="nots"></textarea></div>';
        echo '</article>';
        echo '<div class="clear"></div>';
        echo '</section>';
      };
    ?>

I am getting multiple versions of the same results (4).  Thanks in advance for any help and let me know if you need any other info!


php- foreach statement duplicating results
===

I have a while and foreach loop that I want to use to print all of my results from a MySQL query.  Below is my code for the while statement and the foreach statements. 

WHILE:

    while ($row_questions = mysql_fetch_array($result_questions)) {
     
     $step_number[]      = $row_questions['step_number'];

     if ($row_questions['step_number_sub'] != 0) {
       $step_number_sub[]  = $row_questions['step_number_sub'];
     } else {
       $step_number_sub[]  = "0";
     };

     if ($row_questions['step_required'] != 0) {
       $step_required[]  = "*";
     } else {
       $step_required[]  = "";
     };

     $step_description[] = $row_questions['step_description'];
     $step_outcome[]     = $row_questions['step_outcome'];
     $step_equipment[]   = $row_questions['step_equipment'];
     $test_changes[]     = $row_questions['test_changes'];
  };
  ?>

and my FOREACH:

    <?php

    foreach ($step_number as $i => $step){
        $even_odd = ( '-odd' != $even_odd ) ? '-odd' : '';
        echo '<section class="zebra'.$even_odd.'">';
        echo '<div class="span-2 number"><strong>'.$step_number[$i].'</strong></div>';
        echo '<div class="span-20 description">'.$step_description[$i].'</div>';
        echo '<div class="span-2">'.$step_required[$i].'</div>';
        if ($step_outcome[$i] != null) {
          echo '<div class="span-22 outcome"><strong>Desired Outcome</strong><br>'.$step_outcome[$i].'</div>';
        }
        echo '<div class="clear"></div>';
        echo '<article class="results">';
        echo '<div class="span-10">Did this step match the desired outcome?</div>';
        echo '<div class="span-10">Notes:</div>';
        echo '<div class="span-10">
              <select name="question_'.$step[$i].'" id="question_'.$step[$i].'" required aria-required="true">
              <option name="pass" value="Pass">Yes, this step was completed successfully</option>
              <option name="fail" value="Fail">No, this step failed to complete. See notes below</option>
              </select>
              </div>';
        echo '<div class="span-10"><textarea name="question_'.$step[$i].'" id="question_'.$step[$i].'" class="nots"></textarea></div>';
        echo '</article>';
        echo '<div class="clear"></div>';
        echo '</section>';
      };
    ?>

I am getting multiple versions of the same results (4).  Thanks in advance for any help and let me know if you need any other info!

