You are here: Re: Retreiving The Next AutoIndex « PHP SQL « IT news, forums, messages
Re: Retreiving The Next AutoIndex

Posted by Christoph Burschka on 03/26/07 18:25

Michael wrote:
> I know this is probablly really, really simple, but I can't figure out
> how to retreive the next autoindex in a table, so when I want to
> obtain it, I've been inserting a new row, then finding the unique
> index from some combination of other values that I know will be
> unique.
>
> So I would appreciate you're help in this regard:
> 1. What's the appropriate SQL query to get the next autoindex from a
> table (say 'user').
> 2. How do I obtain that value in PHP (as in, what would I use as the
> index in the array returned by mysql_fetch_assoc())
>
> Thanks!
>

Here's a code snippet (from here: http://php.net/mysql_insert_id):

$SQL = "SHOW
TABLE STATUS
FROM
databaseName
LIKE
'tableName'";

$result = mysql_query($SQL);
$row = mysql_fetch_assoc($result);
$nextInsertId = $row['Auto_increment'];



--
Christoph Burschka

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация