Date: 07/30/02
- Next message: Paul Burney: "Re: [PHP-DB] mysql_fetch_array limit? - more details"
- Previous message: Hutchins, Richard: "RE: [PHP-DB] mysql_fetch_array limit? - more details"
- In reply to: Georgie Casey: "[PHP-DB] Auto Increment Problems...."
- Next in thread: Joel Boonstra: "[PHP-DB] Re: Auto Increment Problems...."
- Reply: Joel Boonstra: "[PHP-DB] Re: Auto Increment Problems...."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Instead of incrementing to find the next row to count them, you dont have to
set the ID if it is auto increment. MySQL will do it for you (and i think it
might fill the holes too). Also, to get the num. of rows just do this -
$get_rows = mysql_query("SELECT * FROM `table`");
$num_rows = mysql_num_rows($get_rows);
"Georgie Casey" <webmaster <email protected>> wrote in message
news:20020729194732.70319.qmail <email protected>
> rite,
>
> my primary key column ("id") is set to auto_increment as usual which is
very
> handy. But when I delete a row, the auto_increment just keeps incrementing
> and there's this 'hole' left where I deleted the row!
>
> Apart from this looking ugly, it poses another problem. In my PHP script
> where I can add new rows, I query the table, checking how many rows in the
> table altogether and set the new id as the next number, but this doesnt
work
> if theres 'holes' in the id field, as the new record tries to overwrite
> another id.
>
> So I've 2 questions
> 1) Can the next auto_increment value be 'set' by a SQL query????
> 2) Can I get a SQL query to INSERT INTO the first 'hole' it finds in the
ID
> column??
>
> TIA
>
>
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Paul Burney: "Re: [PHP-DB] mysql_fetch_array limit? - more details"
- Previous message: Hutchins, Richard: "RE: [PHP-DB] mysql_fetch_array limit? - more details"
- In reply to: Georgie Casey: "[PHP-DB] Auto Increment Problems...."
- Next in thread: Joel Boonstra: "[PHP-DB] Re: Auto Increment Problems...."
- Reply: Joel Boonstra: "[PHP-DB] Re: Auto Increment Problems...."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

