Jump to content

Finding auto_increment (mySQL)


pureDesi

Recommended Posts

here is some code I use

[code]$sql_feilds = "describe $current_table_name";
$result_feilds = connect($sql_feilds);
 
  while ($rows_feilds = mysql_fetch_array($result_feilds))
    {
  fwrite($f, " print(\"<th>$rows_feilds[0]\");\n");
  if ($rows_feilds[3] == 'PRI') {$pk='$row['.$rows_feilds[0].']';}
    } # end while ($rows_feilds = mysql_fetch_array($result_feilds))[/code]

Might not make sense but it basically does a describe on the table and then checks the value of $rows_feilds[3] if it is a PK it will be PRI

-John

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.