skip to Main Content

Can’t get this.
How to determine size of an tep_db_fetch_array inside a while loop?

I would like to do this:

$i=0;
while($a = tep_db_fetch_array($query)){
  if($i==5){
    // start a div i.e.
  }
  //do sth here
  if($i>=count($a)){ 
    //close the div i.e.   
  }
  $i++;       
}

but it is not working, because $a is not the whole array, just a pointer to the actual query result. What i am doing wrong, or how to do it?

2

Answers


  1. Chosen as BEST ANSWER

    Due to FrankZ argument this is the simplest solution:

    $i=0;
    while($a = tep_db_fetch_array($query)){
      if($i==5){
        // start a div i.e.
      }
      //do sth here
      $i++;       
    }
    if($i>=5){ 
      //close the div i.e.   
    }
    

    i was so pretty damn


  2. Try the function tep_db_num_rows, like this:

    $i=0;
    while($a = tep_db_fetch_array($query)){
      //do sth here
      if($i>=tep_db_num_rows($query)){ 
        //do sth other here for the last entry   
      }
      $i++;       
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search