Forum Moderators: coopster
How would I do a query with ORDER BY that selects the bottom to the top?
Order By MyField Desc, I'm assuming somehow you're seeing your table like ordered in ascending order for a given attribute.
How would I make everything thats inserted into the database go on top instead of the bottom?
Sometimes, though this is not a rule, if an index is present during the fetching and records are added to the resultset during a navigation on that index, the results might seems "ordered" by the order in that index. This is specially true when the particular index is a clustered index.
But you should never relay in a casual ordering like this, instead use the proper "Order By" clause for all your queries.
say my table is named x and I have 2 feilds, test and real.
what is the attribute? is that what you mean...? (ORDER BY x Desc)
I just got this mysql book and think it wsas using attributes and I didn't understand. in the book it said ORDER BY expense_date--- is that an attribute?
thanks,
electricocean
Your table will look like this:
CREATE TABLE bla (id INT NOT NULL auto_increment, test VARCHAR(21), real VARCHAR(21), PRIMARY KEY(id));
And your query will be such:
SELECT test, real FROM bla ORDER BY id DESC; (desc means descending - highest is first)
To insert into such table:
INSERT INTO bla(test, real) VALUES('This is test', 'This is real');
Hope this helps
Michal Cibor
$date = mysql_result($result, 0, "date");
$news = mysql_result($result, 0, "news");
this only pulls one piece of news up from the bottom and chges if I change 0 to any number(every one row higher if changed)... How can I fix this?
thanks,
electricocean
SELECT * FROM table LIMIT 0, 10; 0 is the offset (from which row to start) and 10 is how many rows to display.
Then just use
while($row = mysql_fetch_array($result)){} and you have it
Best regards
Michal Cibor