Re: mysql - first element missing

From: Date: Sat, 08 Mar 2003 09:16:29 +0000
Subject: Re: mysql - first element missing
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-26186@lists.php.net to get a copy of this message
Therefor, add a mysql_data_seek($this->result,0) to reset the pointer. Furthermore, instead of the for-next loop, I would use while ($row = mysql_fetch_row($this->result). Edwin Foong wrote:
i guess the problem is the last line of your Query function: $this->ligne = @mysql_fetch_row($this->result); this line fetch the first row of the result. therefore, when you call afficheResultatRequete(...) you start from the second row of the result. Foong "F.Collineau" <f.collineau@voila.fr> wrote in message news:HBBPH2$B7523F15E7CBC78B31DA773D716DD863@voila.fr... Hi, I try to display the result of a mysql request but first element misses ! here is my code: $sql->Query("select marque, reference from base ); $sql->afficheResultatRequete($sql->result,$sql->nbreChamps); function Query ($query) {
        $this->result = @mysql_query($query, $this->id) or MySQL_ErrorMsg
("Impossible de lancer la requete: $query");
        $this->rows = @mysql_num_rows($this->result);
$this->nbreChamps = @mysql_num_fields($this->result); $this->ligne = @mysql_fetch_row($this->result); } function afficheResultatRequete($result,$nbChamps) { for($i=0 ; $row=mysql_fetch_row($result);++$i) { print("<tr>"); $this->color_tab($i); for($j=0;$j<$nbChamps;$j++) { print "<td>"; print((string)$row[$j]); "</td>\n"; } print "</tr>"; } } Whet is the problem ? Thanks Franck ------------------------------------------ Faites un voeu et puis Voila ! www.voila.fr


« previous php.db (#26186) next »