sql correct but in php it skips the first result -


i use this: foreach ($result $row) { $row["testid"], $row["subject"], ... }; output values.
sql works fine when go page shows me output without first element in array.
example if have 5 tests show user shows test 2, 3, 4 , 5 not first 1 in array $result.
code (sorry it's in dutch):

require_once( "common.inc.php" );     require_once( "dataobject.class.php" );      class statistiekaanpassen extends dataobject {         public function toetsen() {             $conn = parent::connect();              $order = isset( $_get["order"] ) ? preg_replace( "/[^ a-za-z]/", "", $_get["order"] ) : "toetsid";              /*sql om alle toetsen op te halen*/             $sql = "select toetsid, onderwerp, puntentotaal, vak                      toets                      not exists                          (select *                          leerlingtoets                          toets.toetsid = leerlingtoets.toetsid ,                          leerlingtoets.gebruikerid = " . $_session["member"]->getvalue( "gebruikerid" ) . " ) order " . $order;              $result = $conn->query($sql);              if ($result->fetchcolumn()) {                 echo "<table id=\"toetstable\">";                 ?>                 <tr>                     <th id="toetstableidth"><?php if ( $order != "toetsid" ) { ?><a href="statistiekenaanpassen.php?order=toetsid"><?php } ?>nr<?php if ( $order != "toetsid" ) { ?></a><?php } ?></th>                     <th id="toetstableidth"><?php if ( $order != "onderwerp" ) { ?><a href="statistiekenaanpassen.php?order=onderwerp"><?php } ?>onderwerp<?php if ( $order != "onderwerp" ) { ?></a><?php } ?></th>                     <th id="toetstableidth"><?php if ( $order != "vak" ) { ?><a href="statistiekenaanpassen.php?order=vak"><?php } ?>vak<?php if ( $order != "vak" ) { ?></a><?php } ?></th>                     <th id="toetstableidth"><?php if ( $order != "puntentotaal" ) { ?><a href="statistiekenaanpassen.php?order=puntentotaal"><?php } ?>puntentotaal<?php if ( $order != "puntentotaal" ) { ?></a><?php } ?></th>                 </tr>                 <?php                     foreach ($result $row) {                         echo "<tr><td class=\"idtd\"><a href=\"statistiekenaanpassen.php?toetsid=" . $row["toetsid"] . "\">" . $row["toetsid"] . "</a></td>                     <td><a href=\"statistiekenaanpassen.php?toetsid=" . $row["toetsid"] . "\">" . $row["onderwerp"] . "</a></td>                     <td><a href=\"statistiekenaanpassen.php?toetsid=" . $row["toetsid"] . "\">" . $row["vak"]. "</a></td>                     <td><a href=\"statistiekenaanpassen.php?toetsid=" . $row["toetsid"] . "\">" . $row["puntentotaal"]. "</a></td></tr>";                     }                 echo "</table>";             } else {                 echo "<p>er zijn nog geen toetsen.<p>";                 echo "<p>of<p>";                 echo "<p>u heeft voor alle toetsen al punten ingegeven.<p>";             }         }     } 


how can output elements, first one?

the fetchcolumn makes first column unavailable, please use

$result->fetch_assoc() 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -