Is there any way to find the maximum number of rows present in a table.
If it is possible, that should solve my problem.
 
- Austin

On Mon, Mar 28, 2011 at 4:29 PM, Austin Einter <austin.einter@gmail.com> wrote:
Thanks Nancy.
Do you mean that in my code I should not put the value for "cid". That means $lastid (in red) should be removed.
 
 
$lastid = 0;
  for($delta = 0; $delta < $all_companies; $delta++)
  {
 $lastid = db_last_insert_id(rs_companies, cid) + 1;
      db_query(
    'INSERT INTO {rs_companies} ( cid, uid, prevcompany, joindate, releasedate) '
      ."VALUES (%d, '%d', '%s', '%d', '%d')",
 $lastid, 
$user->uid

 
Regards
Austin
On Mon, Mar 28, 2011 at 4:20 PM, nan wich <nan_wich@bellsouth.net> wrote:
You don't need to provide the value for an auto increment field. "Db_last_insert_id()" is how you get the value after the insert, if you need it at all.
 

Nancy

 

Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.




From: Austin Einter
 
I have a table, where 'cid' field is of type "serial".
 
$lastid = 0;
  for($delta = 0; $delta < $all_companies; $delta++)
  {
 $lastid = db_last_insert_id(rs_companies, cid) + 1;
      db_query(
    'INSERT INTO {rs_companies} ( cid, uid, prevcompany, joindate, releasedate) '
      ."VALUES (%d, '%d', '%s', '%d', '%d')",
 $lastid,