I have just tried the following which is functionally identical to your code:-
$query=mysql_query("SELECT * FROM Steel_Users ORDER BY UserID DESC LIMIT 3");
while ($row = mysql_fetch_array($query)) {
echo $row['UserID'] . ",<br />";
}
And I get the output:-
114,
113,
112,
This is correct but at variance with your output. If you strip your code down
to the same bare minimum:-
$query=mysql_query("select * from newsa ORDER BY id DESC LIMIT 3");
while ($row = mysql_fetch_array($query)) {
echo $row['id'] . ",<br />";
}
Do you still get the wrong output?
Charlie
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Tedit kap
Sent: 07 May 2008 01:37
To: [email protected]
Subject: Re: [php_mysql] DESC in mysql results
I would have to agree with Charlie. When I tried LIMIT 0,3 it did not change
anything. I am still looking for a solution. Here is the complete php statement
including mysql query, and my question again....
The problem is, it displays as:
row with id 98
row with id 99
row with id 100
The question is, I want it to display as :
row with id 100
row with id 99
row with id 98
How can I achieve this?
Here is the code:
$query=mysql_query("select * from newsa ORDER BY id DESC LIMIT 3");
while ($row = mysql_fetch_array($query)) { echo"<p class='newstitle1'>" .
$row['date']."<br/>". $row['title'] .$row['id']. "</p>".
"<p id=newstext1>" . $row['par1'];
$b=$row['id'];
echo"<a href='xxxxxxx.php?id=$b'".">"."(more...)"."</a>" ; }
----- Original Message ----
From: Charlie Markwick <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, May 6, 2008 1:00:23 AM
Subject: RE: [php_mysql] DESC in mysql results
I'm puzzled how this changes things. At
http://dev.mysql. com/doc/refman/ 5.1/en/select. html it says:-
"... LIMIT row_count is equivalent to LIMIT 0, row_count. ..."
So "select * from newsa ORDER BY id DESC LIMIT 0,3" is functionally identical
to "select * from newsa ORDER BY id DESC LIMIT 3". Indeed for me it returns
exactly the same result and in the same order. I feel that the original problem
arises not from the select statement but the PHP that displays the rows. Or am
I missing soemthing here?
Charlie
-----Original Message-----
From: [EMAIL PROTECTED] ps.com [mailto:[EMAIL PROTECTED] ps.com] On Behalf Of
HardyBoyz
Sent: 05 May 2008 09:24
To: [EMAIL PROTECTED] ps.com
Subject: RE: [php_mysql] DESC in mysql results
The query is
select * from newsa ORDER BY id DESC LIMIT 0,3
look at the query above carefully.
From: [EMAIL PROTECTED] ps.com [mailto:[EMAIL PROTECTED] ps.com] On Behalf Of
Tedit kap
Sent: 04 May 2008 01:42
To: [EMAIL PROTECTED] ps.com
Subject: [php_mysql] DESC in mysql results
Hi all,
$query=mysql_ query("select * from newsa ORDER BY id DESC LIMIT 3");
while ($row = mysql_fetch_ array($query) ) { echo"....... .......
if we say the id of rows goes from 1 to 100, so the last row's id is 100,
this code displays the results for the ids as follows:
row with id 98
row with id 99
row with id 100
The question is, I want it to display as :
row with id 100
row with id 99
row with id 98
How can I achieve this?
(if i try ASC instead of DESC it displays rows with ids 1,2,3 - that is not
what I want)
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
[Non-text portions of this message have been removed]
------------------------------------
The php_mysql group is dedicated to learn more about the PHP/MySQL web database
possibilities through group learning. Yahoo! Groups Links