Re: Getting last id from database
| From: | Mihail Bota | Date: | Thu, 03 Oct 2002 16:17:41 +0000 |
| Subject: | Re: Getting last id from database | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-16143@lists.php.net to get a copy of this message | ||
Davy,
maybe you can try something like "select max(id) as maxid from poll".
Mihai
On Thu, 3 Oct 2002, Davy Obdam wrote:
> Hiya people,..
>
> I have a script and i need to get the last id from the database. I have
> to get this id to determine whats the latest poll and display that poll
> on the page. Now i use this:
>
> if(!$poll)
> {
> $select = mysql_query("SELECT id FROM poll");
> $poll = mysql_num_rows($select);
> }
>
> Well everything goes alright if u dont remove any polls.. this just
> counts the mumber of rows in the database. Can anyone help me with and
> idea how to get the latest id from the database, so that i am able to
> delete polls from the database. I ve tried mysql_insert_id(); but i cant
> get it to work. Thanks already for your help.
>
> Thanks,..
>
> Davy Obdam
> mailto:info@davyobdam.com
> url: http:///www.davyobdam.com
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>