[straying OT, but...]
> 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);

Oh my, don't do that!  If you only want to get the number of rows in a
table, don't bog down the MySQL server by doing a 'SELECT *' on it.
This could be a *ton* of data...

Why not use MySQL's built-in counting functionality:

  $result = mysql_query('SELECT count(*) AS count FROM table');
  $count_arr = mysql_fetch_assoc($result);
  $count = $count_arr['count'];

MySQL will be able to simply count rows a lot faster than actually
SELECTing all of the data.

Of course, if you're counting rows just to find out what the next value
for an ID is, then, as you already said, you're doing the wrong thing.


[ joel boonstra | [EMAIL PROTECTED] ]

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to