--- Pete <[EMAIL PROTECTED]> wrote:

> 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.

I thought mysqli_num_rows() returns how many records
there are in a table.

> >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.

Yes, actually i have it set to auto_increment and
int(4). So in my case the values in ID column start
incrementing in proper way. :) So it's working for me
if I delete rows from at the end of the table.
Otherwise I have to modify table structure manually,
which I realize doesn't really work in real world. But
that's a good learning experience for me and I thank
you guys for teaching me this stuff. I have a LOT to
learn :) ).

Anna Vester

http://veanndesign.com
http://reviews.veanndesign.com

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


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