# Displaying most recent entry from db

**URL:** <https://forum.kirupa.com/t/displaying-most-recent-entry-from-db/171290>\
**Category:** Uncategorized\
**Created:** [December 3, 2005, 9:21pm UTC](https://forum.kirupa.com/t/displaying-most-recent-entry-from-db/171290 "2005-12-03T21:21:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dru\_nasty](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dru\_nasty](https://forum.kirupa.com/u/dru_nasty)\
**Post date:** [December 3, 2005, 9:21pm UTC](https://forum.kirupa.com/t/displaying-most-recent-entry-from-db/171290/1 "2005-12-03T21:21:24Z")

</div>

I’m trying to learn the building blocks of php w/mysql.

I have a table called ‘testTable’ with two columns, ‘id’ and ‘testField’.  
id is auto\_incremented . I’ve got 4 rows basically like this:

id testField  
1 some text  
2 more text  
3 some more text  
4 and more text

I would just like to get the latest entry from the db which would be “and more text”.

so here’s my code so far:

```php

<?php
$conn = mysql_connect("localhost", "myusername","mypassword");
mysql_select_db("mydatabase_name", $conn);

$sql = "SELECT testField FROM testTable WHERE id=max(id)";
$result = mysql_query($sql, $conn) or die(mysql_error());
echo "$result";
?>

```

And the result i get from that query is this “Invalid use of group function”.

How would i get only the latest entry from the db to display?
