Re: mysql - first element missing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
HBBPH2$B7523F15E7CBC78B31DA773D716DD863@voila.fr">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




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux