Fetching array then reversing it


Posted on 16th Feb 2014 07:03 pm by admin

Hi, I have a simple problem, I'll try to explain it as best I can:
News entries in my database are ordered from oldest to newest. In order to pull out the last 10 lines I do this:
$newsquery=mysql_query("SELECT * FROM news ORDER BY timestamp DESC LIMIT 10");
while($row = mysql_fetch_array($newsquery)){
echo '<b>' .$row['line']. '</b>
';
}
It spits out something like this:
most recent news in db
second most recent news in db
third most recent news in db
etc...

The problem is I need to flip that list so the oldest of the 10 is on top and the newest is on bottom.

What I've tried:
$row = array_reverse(mysql_fetch_array($newsquery)))
array_reverse didn't seem to do anything.

I've also read that it can be done with a subquery, but the explanation wasn't that great.
Any help would be much appreciated!

No comments posted yet

Your Answer:

Login to answer
77 Like 8 Dislike
Previous forums Next forums
Other forums

Xacute search within SQL results
I have a query that is pulling data, and I want to return a specific value from the results of that

help with this code please?
Hello,

I am trying to build a remote upload script for my image hosting site.

I am usi

[Need Help] php timing issues
I don't know what is going wrong. I need some help with being able to set an image at 9:00am Colorad

Find only certain URLs from page ... regex (semi-complete script)
Hi guys,

What I need to do is take a page & extract all the URLs from the page &a

login to other site by sending post variables
hey,

here is my problem: my school gave me a mail account for school-stuff use. they mail us

Need help/w Page: 1,2,3,4 function!
So I have this code im working on where it's ment to display seperate pages having 20 logs each
I

type check while uploading
Hi Everyone,

How can I check the exact type of a file while uploading on my site?

Here

What makes a script your own?
If someone finds a login script online, and changes some variable names around and some other minor

Calculus Help (and by help I mean homework)
Hrmmm, I hate posting about math homework, partly because it's homework, and partly because I hate w

Is it possible to view php source code??
Hi All

I was just wondering if it's possible to view a websites php source code?
I know

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash