reverse order
Posted: Tue Oct 31, 2006 5:45 pm
I have a query and am trying to reverse the results. I tried using "reverse_array" but it didn't work. Here is a quick example of what I have.
I tried using the function revers_array on $result but it didn't work. Now, I'm not sure what kind of variable $result is. Anyone have any ideas on how to reverse the order of things either through PHP or SQL.
Thanks in advance.
Code: Select all
$query = "SELECT wp_posts.post_title, wp_posts.post_date, wp_posts.post_excerpt, wp_posts.ID, wp_postmeta.meta_value
FROM wp_posts, wp_post2cat, wp_postmeta
WHERE wp_post2cat.category_id = '3'
AND wp_post2cat.post_id = wp_posts.ID
AND wp_postmeta.post_id = wp_posts.ID
ORDER BY wp_posts.post_date";
$result = mysql_query($query);
if (!empty($result))
{
$numresults = mysql_num_rows($result);
if ($numresults > 0)
{
for ($read_ctr=1; $read_ctr<=$numresults; $read_ctr++)
{
$row = mysql_fetch_array($result);
// input ITEM and VALUE
$error="0";
$title = $row['post_title'];
$articleid = $row['ID'];
$image = $row['meta_value'];
$excerpt = $row['post_excerpt'];Thanks in advance.