Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

SQL ORDER BY not working ?

Featured Replies

Hi, im echo'ing some data from my database using sql and php.

 

<?php

$blog_url="blog";//config url of aw_blog
   $write = Mage::getSingleton('core/resource')->getConnection('core_write');
   $readresult=$write->query("SELECT title, created_time, identifier, post_content FROM aw_blog WHERE status=1 LIMIT 5");//select from db last 5 post
   echo "<ul>";
   while ($row = $readresult->fetch() ) {
       echo "<li>";
	echo "<div class='postTitle'><h2><a href='$blog_url/" . $row['identifier'] . "'>" . $row['title'] . "</a></h2>";
	echo "<h3>" . $row['created_time'] . "</h3></div>";
	echo "<div class='postContent'>" . substr($row['post_content'], 0, 250) . "</div>";
	echo "</li>";
   }
   echo "</ul>"; 

?>

 

The above works fine however its listing old entries where id like to list recent ones. Usually id use something like this to set the order ...

 

ORDER BY identifier

 

So putting that into the above should look like ..

 

$readresult=$write->query("SELECT title, created_time, identifier, post_content FROM aw_blog ORDER BY identifier WHERE status=1 LIMIT 5");//select from db last 5 post

 

When i add the above my sql query stops working so i must have something wrong ?

  • Author

Just spent an hour on that little error !! Well at least ill know for next time.

Thanks henbast rep added ;-)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.