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)){
Did you know?Explore Trending and Topic pages for more stories like this.
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

HOW to get the bind variables list.
I've the following problem : I've some SQL queries stored in my DB as VARCHAR2 values.
I need t

Calling a Procedure with IN & OUT Parameters
Hello,

I usually call my procedures using the following way

declare variable e

Simple PHP/Java Help..
Hi,
I'm trying to build a little program to do with calculating postage. Unfortunately i haven't

Character Sets/Collations Stuff
Can someone please give me a check list of things I must do to setup all the charset stuff for my ph

Help with PHP Email Script
Hi guys,

I'm a newbie to php and need help with the script below:

At the moment when I

IDOC error
Hi, When i send IDOC from ECC system to MII there is no problem ECC side, i says message sent succe

PHP IMAGE UPLOAD SCRIPT
Hi for the last week i have been looking for scripts that will upload a photo to a certain folder wh

Need a Timecode Class...
Not a Time Stamp, Time Code. Format is a bit different. HH:MM:SS:FF where FF is Frames. I dont re

SAP BCS. BPS
Hi all,

I am seeking reading note on the following in BW

BCS, BPS
ADVANCE

2 things: enter doesn't work in IE & empty form
i have this search form that works well except for 2 things.

1) on IE when i hit enter instea

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