Hi Mike,
Yes, it was just the date of the most recent message I wanted.
We may have been at cross purposes then.

<<< Message from Jun 19 >>>
Hi Pete,
I'm using a mysql database.
What I am doing is getting just the date of the latest message left, which 
displays on a previous page.
i.e. Last message was posted: date time etc.

I've refined formatting the date and finished up with this in the menu page:
<?php
error_reporting(0);
require_once($_SERVER['DOCUMENT_ROOT']."/_private/opendb.php");
$sql = "SELECT
        DATE_FORMAT(logged, '%a %D %M %Y at %r') AS logged
        FROM forum
        ORDER BY logged
        DESC LIMIT 1";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo "<b>Last message: <i>".$row['logged']."</i></b>";
mysql_close();
?>

Have also managed to put 'logged', my PRIMARY KEY as the 1st field in my table 
(used a regex to rearrange the sql dump). It took a few goes with EditPlus, but 
I got there.

I should really rename 'logged' to 'logged_id' or 'logged_primary', may do that 
later.

I think it's sorted now (pun), and I'm understanding dbs better.

The sort (my words) was a big misunderstanding by me, as both my versions of 
phpmyadmin have a 'sort'. Yes, I now realise that this just displays, not 
permanently sort the records. To a newbie like me, I thought 'sort' would 
actually sort.

Still a lot to learn from you guys, thanks.
Regards, Bob.


----- Original Message ----- 
From: "Mike Franks" <[EMAIL PROTECTED]>

> On 6/20/2005, "Bob" <[EMAIL PROTECTED]> wrote:

>>$result = mysql_query("SELECT UNIX_TIMESTAMP(MAX(logged)) AS logged FROM 
>>forum");
>>$result = mysql_query("SELECT UNIX_TIMESTAMP(logged) AS logged FROM forum 
>>ORDER BY logged DESC LIMIT 1");
> 
> Bob - this is not the query you originally said you wanted to perform.
> Originally, you wanted the entire record for the latest transaction.
> That is:
> 
> "SELECT *, UNIX_TIMESTAMP(logged) AS logged FROM forum ORDER BY logged
> DESC LIMIT 1"
> 
> - or -
> 
> "SELECT *, UNIX_TIMESTAMP(logged) AS logged FROM forum WHERE logged =
> MAX(logged)"
> 
> I'd be very interested in seeing the performance results of these two
> queries, and suspect they'll be very similar in a table with less than
> 1000 records, with or without an index on the 'logged' column.
> 
> It would be REALLY interesting to see the results on a table with 100,000
> records! <g>
> 
> Regards,
> Mike



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to