Does anyone know how to reverse the output of a MySQL query with PHP?
I tried storing it into an array and flipping, but no luck.
Any ideas?
Does anyone know how to reverse the output of a MySQL query with PHP?
I tried storing it into an array and flipping, but no luck.
Any ideas?
PM me if you need any help with math.
I can try to help you with anything!
The best way to contact me is by email, which you can find on my website: http://wizzup.org
I also get email notifications of private messages, though.
Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
Documentation | Source | Simba Bug Tracker on Github and Villavu )
My (Blog | Website)
This is what I had:
This is what I tried:PHP Code:<?php
$dbconnect = mysql_connect("localhost", ":norris:", ":norris:");
mysql_select_db(":norris:", $dbconnect);
$articles = mysql_query("SELECT * FROM Articles");
while ($row = mysql_fetch_array($articles))
{
print('<a class="pagetitle" href="' . $row['url'] . '">' . $row['title'] . ' </a>');
print("\n<br />\n");
print('<div class="creator">' . $row['creator'] . '</div>');
print("\n<br />\n");
print('<div class="description">' . $row['description'] . '</div>');
print("<hr>\n");
}
mysql_close($dbconnect);
?>
I want to make the query:PHP Code:<?php
$dbconnect = mysql_connect("localhost", ":norris:", ":norris:");
mysql_select_db(":norris:", $dbconnect);
$articles = mysql_query("SELECT * FROM Articles");
$temp = 0;
while ($row = mysql_fetch_array($articles))
{
$row['title'] = $title[$temp];
$row['description'] = $description[$temp];
$row['creator'] = $creator[$temp];
$row['url'] = $url[$temp];
$temp++;
}
$temp = 0;
while ($temp < count($title))
{
print('<a class="pagetitle" href="' . $url[$temp] . '">' . $title[$temp] . ' </a>');
print("\n<br />\n");
print('<div class="creator">' . $creator[$temp] . '</div>');
print("\n<br />\n");
print('<div class="description">' . $description[$temp] . '</div>');
print("<hr>\n");
}
mysql_close($dbconnect);
?>
Become:PHP Code:1
2
3
4
5
6
I can't store it into an array for some reason...PHP Code:6
5
4
3
2
1
Any ideas why?
Last edited by Blender; 05-07-2009 at 11:03 PM.
PM me if you need any help with math.
I can try to help you with anything!
Oops! Never mind...
I typed:
Instead of:PHP Code:$row['title'] = $title[$temp];
$row['description'] = $description[$temp];
$row['creator'] = $creator[$temp];
$row['url'] = $url[$temp];
Fixed!PHP Code:$title[$temp] = $row['title'];
$description[$temp] = $row['description'];
$creator[$temp] = $row['creator'];
$url[$temp] = $row['url'];
Thanks for making me type it out!
PM me if you need any help with math.
I can try to help you with anything!
Can't you put "ORDER BY `title` DESC" in there?
Ce ne sont que des gueux
It is a forum that I made.
It displayed the oldest topics first, and newest last.
I needed to flip it around.
PM me if you need any help with math.
I can try to help you with anything!
Well then "ORDER BY `post_date` DESC"?
Ce ne sont que des gueux
Just use ORDER BY <ENTITY1> [ENTITY2...] as Floor66 stated. Also, ASC = Ascending Order, Desc = descending order. Each Entity can be ASC or DESC.
The best way to contact me is by email, which you can find on my website: http://wizzup.org
I also get email notifications of private messages, though.
Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
Documentation | Source | Simba Bug Tracker on Github and Villavu )
My (Blog | Website)
There are currently 1 users browsing this thread. (0 members and 1 guests)