php - $row=mysql_fetch_array($result); only returns even rows -


we have code:

$rowarray; $rowid = 1; $query = "select idcentros centros"; $result = mysql_query($query); $numrows=mysql_num_rows($result);  while($row = mysql_fetch_array($result)){             $rowarray[$rowid] = $row['idcentros'];            $rowid = $rowid +1;     }   

$numrows returns 4 (the rows have in table)...but unkown reason loop starts retrieving 2º row next retrieves 4º row , ends loop ($row =false). understand generic code , table definition this:

column idcentros int(11)      pk notnull autoincremental column nombre    mediumtext 

what happening? in advance...

try this:

$query = "select idcentros centros"; $result = mysql_query($query); $numrows=mysql_num_rows($result); $rowarray = array(); while($row = mysql_fetch_array($result)) {    array_push($rowarray,$row); } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -