Jump to content

[SOLVED] while loop won't process last row in array


jmurch

Recommended Posts

 

I'm using this while to loop thru my array:

 

while ($row = oci_fetch_array($s, OCI_NUM+OCI_RETURN_NULLS)) {

 

It's leaving the last row unprocessed each time.  How can I modify the above statement to loop one extra time after the normal count?

 

TIA, Jeff

Link to comment
Share on other sites

It's likely that either your query is not selecting all the rows you think it is or your code is discarding or not using all the results. Post all your code from where the query statement is generated through to the end of your code that is using the results.

Link to comment
Share on other sites

PFM,

 

Here is the entire while loop. I have confirmed that there is one row left in the array after the while loop thinks it's done:

 

$s = oci_parse($c, "select * from triton.LOOKUP_SERIAL_NBR_V

 

                    where LOOKUP_SERIAL_NBR_V.parent_serial_number like '%$serial_number'");

 

 

 

 

 

oci_execute($s);

 

$parent_row = oci_fetch_array($s, OCI_NUM+OCI_RETURN_NULLS);

 

 

 

if($parent_row[0]) {

 

echo "<span class='content_blue_header'>";

 

    echo "<br><b><u>Parent information:</u></b>";

 

echo "</span>";

 

echo "<br>";

 

echo "<br>";

 

echo "<div class='serial_number_row'>";

 

echo "<div class='serial_number_title'>Serial number:</div>";

 

    echo "<div class='serial_number_value'>".$parent_row[0]."</div>";

 

echo "</div>";

 

 

 

$date = $parent_row[1];

 

$ship_date = date('m-d-Y', strtotime($date));  //

 

//$labor_warranty_date = date('m-d-Y', strtotime($date . ' + 90 DAYS'));  // 90 days in the future

 

$parts_warranty_date = date('m-d-Y', strtotime($date . ' + 13 MONTHS'));  // 13 months in the future

 

 

 

echo "<div class='serial_number_row'>";

 

    echo "<div class='serial_number_title'>Model:</div>";

 

    echo "<div class='serial_number_value'>".$parent_row[2]."</div>";

 

echo "</div>";

 

 

 

echo "<div class='serial_number_row'>";

 

    echo "<div class='serial_number_title'>Manufacture date:</div>";

 

    echo "<div class='serial_number_value'>".$ship_date."</div>";

 

echo "</div>";

 

 

 

//echo "<div class='serial_number_row'>";

 

//    echo "<div class='serial_number_title'>Labor warranty good until:</div>";

 

//    echo "<div class='serial_number_value'>".$labor_warranty_date."</b></div>";

 

//echo "</div>";

 

 

 

echo "<div class='serial_number_row'>";

 

    echo "<div class='serial_number_title'>Parts warranty good until:</div>";

 

    echo "<div class='serial_number_value'>".$parts_warranty_date."</div>";

 

echo "</div>";

 

 

 

echo "<br>";

 

echo "<br>";

 

 

 

echo "<div class='serial_number_row'>";

 

    echo "<span class='content_blue_header'><b><u>Child component information:</u></b></span>";

 

echo "</div>";

 

echo "<br>";

 

echo "<br>";

 

while ($row = oci_fetch_array($s, OCI_NUM+OCI_RETURN_NULLS)) {

 

echo "<div class='serial_number_output_row'>";

 

echo "<div class='serial_number_row'>";

 

    echo "<div class='serial_number_title'>Component:</div>";

 

    echo "<div class='serial_number_value'>".str_replace(', ,',',',str_replace('|', ', ', $row[5]))."</div>";

 

echo "</div>";

 

 

 

echo "<div class='serial_number_row'>";

 

    echo "<div class='serial_number_title'>Part number:</div>";

 

    echo "<div class='serial_number_value'>".$row[6]."</div>";

 

echo "</div>";

 

 

 

echo "<div class='serial_number_row'>";

 

    echo "<div class='serial_number_title'>Serial number:</div>";

 

    echo "<div class='serial_number_value'>".$row[3]."</div>";

 

echo "</div>";

 

 

 

echo "<div class='serial_number_row'>";

 

    echo "<div class='serial_number_title'>Manufacture date:</div>";

 

    echo "<div class='serial_number_value'>".$row[4]."</div>";

 

echo "</div>";

 

 

 

    $part_number_pic = $row[6].".jpg";

 

    $tn_path = 'http://www2.website.compartner/parts_programs/field_replaceable_parts_lists/parts_images/frp_tn/'.$part_number_pic;

 

    $pic_path = 'http://www2.website.com/partner/parts_programs/field_replaceable_parts_lists/parts_images/frp/'.$part_number_pic;

 

 

 

echo "<div class='serial_number_row'>";

 

    echo "<div class='serial_number_title'>Image:</div>";

 

    echo "<div class='serial_number_value'><a href='$pic_path' rel='lightbox'><img src='$tn_path' border='0'></a></div>";

 

echo "</div>";

 

echo "<!--[if IE]><br style='clear:both;' /><![endif]-->";

 

 

 

    if(!empty($row[7])) {

 

echo "<div class='serial_number_row'>";

 

 

 

echo "<div class='serial_number_child_line'>";

 

echo "<img src='http://www2.website.com/partner/images/parent_child_line.png'>";

 

echo "</div>";

 

 

 

echo "<div class='serial_number_child_child'>";

 

 

 

echo "<div class='serial_number_row'>";   

 

echo "<div class='serial_number_alternate_title'>Alternative part for ".$row[6]."</div>";

 

echo "</div>";

 

 

 

echo "<div class='serial_number_row'>";

 

echo "<div class='serial_number_title'>Component:</div>";

 

    echo "<div class='serial_number_value'>".str_replace(', ,',',',str_replace('|', ', ', $row[8]))."</div>";

 

echo "</div>";

 

       

 

echo "<div class='serial_number_row'>";

 

echo "<div class='serial_number_title'>Alt. part number:</div>";

 

    echo "<div class='serial_number_value'>".$row[7]."</div>";

 

echo "</div>";

 

 

 

echo "<div class='serial_number_row'>";

 

echo "<div class='serial_number_title'>Reciprocal:</div>";

 

    echo "<div class='serial_number_value'>".$row[9]."</div>";

 

echo "</div>";

 

       

 

echo "<div class='serial_number_row'>";

 

echo "<div class='serial_number_title'>Alt. Part Manufacture date:</div>";

 

    echo "<div class='serial_number_value'>".$row[10]."</div>";

 

echo "</div>";

 

 

 

            $part_number_pic = $row[7].".jpg";

 

            $part_number_b_pic = $row[7]."b.jpg";

 

            $tn_path = 'http://www2.website.com/partner/parts_programs/field_replaceable_parts_lists/parts_images/frp_tn/'.$part_number_pic;

 

            $tn_path_b = 'http://www2.website.com/partner/parts_programs/field_replaceable_parts_lists/parts_images/frp_tn/'.$part_number_b_pic;

 

            $pic_path = 'http://www2.website.com/partner/parts_programs/field_replaceable_parts_lists/parts_images/frp/'.$part_number_pic;

 

     

 

echo "<div class='serial_number_row'>";   

 

    echo "<div class='serial_number_title'>Image:</div>";

 

echo "<div class='serial_number_value'><a href='$pic_path' rel='lightbox'><img src='$tn_path' border='0'></a></div>";

 

echo "</div>";

 

 

 

 

 

echo "</div>";

 

echo "</div>";

 

echo "<!--[if IE]><br style='clear:both;' /><![endif]-->";

 

 

 

    }     

 

echo "<br style='clear:both;' />";

 

     

 

echo "</div>";

 

}

 

 

 

oci_free_statement($s);

 

} else {

 

    echo "<div class='serial_number_row'><font size='3' color='red'>Serial number not found.</font></div>";

 

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.