Hello Everybody
I am trying to display the value of an array in which is passed from one php page to another php page, but I am getting only last element value. Where as when I checked the array content using print_r() it is showing all the values. This is where I need to the value to be displayed -

<tr class="bgcolor_02">
  <?php
    if(is_array($subject_array))
    {
    foreach($subject_array as $each_subject)
    {
  ?>
  <td width="9%"> <?php echo ucfirst($each_subject['es_subjectname']);?> </td>
  <?php } } ?>
</tr>
<tr>
  <?php
  $inc=0;
  foreach($subject_array as $each_subject)
  {
  ?>
  <td> <?php echo $array_roll[$inc]; ?> </td>
  <?php $inc++;
  }?>
</tr>

And here is the code from where values are fetched and passed -

if(count($errormessage)==0)
{
  $cout=0;
  if(isset($classid))
  {
    $subject_array=$db->getRows("SELECT * FROM es_subject WHERE es_subjectshortname='".$classid."'");
    if(is_array($subject_array))
    {
       foreach($subject_array as $each_subject)
       {
      $array_subject[$each_subject['es_subjectid']]=$each_subject['es_subjectname'];

      $sub_id=$each_subject['es_subjectid'];
      $roll_array=$db->getRow("SELECT es_exam_detailsid FROM es_exam_details WHERE academicexam_id='".$exam_id."' AND subject_id='".$sub_id."'");               
          $array_roll[$cout]=$roll_array['es_exam_detailsid'];
      print_r($array_roll[$cout]."  ");
    }
      }
   }
}

By this code I am getting Output like this

ENGLISH GEOGRAPHY ACCOUNTANCY COMPUTER ECONOMICS
33

Where as output must be

ENGLISH GEOGRAPHY ACCOUNTANCY COMPUTER ECONOMICS
26            27                   31                       32                 33

I am able to see the values on top of the page due to print_r(); which is like this
26 27 31 32 33

Need some help on this problem why I am not getting all values.

Thank you.

you forgot to increment cout, add line after number 15,

print_r($array_roll[$cout]."  ");
 $cout++
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.