Re: Highest ID
| From: | J!M | Date: | Tue, 29 Aug 0000 15:15:28 +0000 |
| Subject: | Re: Highest ID | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2461@lists.php.net to get a copy of this message | ||
Try this:
$getmax = mysql_query("Select Max(id) as maxid From yourtable")
or die("query getmax failed");
while ($row = mysql_fetch_object ($getmax)) {
print("$row->maxid is the max id");
}
J!M
> Hi,
>
> I've got a table whith a primary key as auto incrementing field.
> I want to know what the highest ID is.
> I know you can use mysql_insert_id but that is only after an insert. I
> want to know it whithout doing an insert which gives me an $insert_id,
> delete that $insert_id and nowing that the highest is $insert_id - 1;
>
> any suggestions ?
>
> J.S. de Boer
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>