hi,
I am facing a small but never the less itching problem.
I try to order a table with this basic select statement:

// basic SELECT-Statement
$select = "SELECT DISTINCT ID, newsdate, newstime, newshead, newstext";
$from = " FROM news";
$where = " WHERE ID > 0";
$how = " ORDER BY newsdate DESC LIMIT 0, 30";

I would like to see the newest message always on top of the list.
everything works fine as long there is only one message a day, otherwise the oldest message of the day will be on top, till the date changes.
any ideas ?

thanks a lot
stephan

    What happens if you include the time in your order by clause?

    $how = " ORDER BY newsdate, newstime DESC LIMIT 0, 30";

      if I do that, everything is ordered nicely, but the newest entry sits at the bottom of the list ( oldest on top )
      so the DESC seems not to work anymore.

        same as:
        $how = " ORDER BY newsdate DESC LIMIT 0, 30";
        the newest date on top, but not the newest time.

          somebody has shown me this one:
          $how = " ORDER BY ID DESC LIMIT 0, 30";

          and it works fine !

          thanks again.

            My example will work if your datatypes for newsdate and newstime are date and time, respectively.

            edit: Oh, using an autoincrement ID is much easier.

              Write a Reply...