First row not selecting? or last using DESC

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Darkside
Forum Commoner
Posts: 43
Joined: Wed Oct 30, 2002 4:18 pm

First row not selecting? or last using DESC

Post by Darkside »

I'm using the below code to select my rows.

Code: Select all

$result = mysql_query("SELECT ID, Name, Subject, Messto, Messages, date, Readmes FROM messages WHERE Messto = '" .$userїname]. "'");
$row = mysql_fetch_array($result);
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
For some very odd reason even when i send 5 messages to user name 'darkside' the first row doesnt echo out? its just not there.

I only noticed this because I wanted to replace the above $result for

Code: Select all

$result = mysql_query("SELECT ID, Name, Subject, Messto, Messages, date, Readmes FROM messages WHERE Messto = '".$userїname]."' order by 'ID' DESC");
and here it was that last once assed and not the first?
I've got alot of code here so I'm not sure wot code ppl need to help me fix this but i think it has to be something to do with when I select the rows? I even tried just

Code: Select all

$result = mysql_query("SELECT ID, Name, Subject, Messto, Messages, date, Readmes FROM messages");
Any help wouldnt go a miss! thanks
darkside
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

Code: Select all

$result = mysql_query("SELECT ID, Name, Subject, Messto, Messages, date, Readmes FROM messages WHERE Messto = '" .$userїname]. "'"); 
$row = mysql_fetch_array($result); 
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

remove this line :

Code: Select all

$row = mysql_fetch_array($result);
Post Reply