In message <[EMAIL PROTECTED]>,
Anna Vester <[EMAIL PROTECTED]> writes
>For example, <PEDANTIC MODE>my table has 10
>records</PEDANTIC MODE>.
>The AUTO_INCREMENT value is 11. I then delete 2 last
>records. I have 8 recs left, and AUTO_INCREMENT value
>is still 11, so I count the rows and add 1. Like this:
>
>$numresults = mysqli_query($link, "SELECT bookmarkId
>FROM bookmark");

This just gets the value of the last record in the table.  If you REALLY
want to count the number of records,
>$numresults = mysqli_query($link, "COUNT(*) FROM FROM bookmark");

>
>
>$numrows = mysqli_num_rows($numresults);
>$autoIncrement = $numrows + 1;
>$fixAutoIncrementValue = 'alter table bookmark
>AUTO_INCREMENT = '.$autoIncrement.'';
>
>That fixed the AUTO_INCREMENT issue in this situation.

Actually, it probably screwed it up.  You now have all your records with
the ID of 12.

>But what if i delete a record from the middle of the
>recordset, do I need to look at the last record in
>that database and then add 1 to that value?

Check the structure of your table.  Define the field of the ID as
integer (or int(11)), make it the primary key, make it auto_increment,
then leave it alone.


--
Pete Clark

Free advertising for your website, business, or organisation at:
http://www.hotcosta.com/resources.php




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




SPONSORED LINKS
Php mysql Job postings


YAHOO! GROUPS LINKS




Reply via email to