ammarali29 ammarali29 - 1 year ago 94
PHP Question

array last element is not get printed

I have an array which is getting some id's form db table (which are 5 id's) and then i have to fetch more data based on these id's. i got data against each id except last one number 5.
i don't know what the problem is. any kind of help

here is my piece of code:

for ($i=0; $i<$count; $i++)
$qry_to_find_section_id = "SELECT DISTINCT sc.sectionID as SectionID FROM scoreanalysis as sc WHERE sc.formatID =43 and sc.waveID = 29 and sc.territoryID = '".$locations_id_arr[$i]."'";

$qry_to_find_section_id_rs = mysql_query($qry_to_find_section_id) or die($qry_to_find_section_id."<br><br>".mysql_error ());
$section_id_arr= array();
while($rs_section_id = mysql_fetch_array($qry_to_find_section_id_rs))
$section_id_arr [] = $rs_section_id['SectionID'];

$count_section_id = count($section_id_arr);
for($j=0; $j<$count_section_id; $j++)
echo $section_id_arr[$j].' ';
} echo '<br>';


Answer Source



    $count = count($locations)-1;
    for($i=0; $i<=$count; $i++)
            // inner code


    $count_section_id = count($section_id_arr)-1;
    for($j=0; $j<=$count_section_id; $j++)
            echo $section_id_arr[$j].' ';

here is a link

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download