0
$sql2 = mysql_query("select MAX(column1) FROM sampledb");

while($iii=mysql_fetch_row($sql2))

{

$iii['MAX(column1)'];

}
$numplus = $iii+1;

echo"$numplus";

im a newbie pls help me T_T

xdazz
  • 158,678
  • 38
  • 247
  • 274

1 Answers1

2

What you are looking for here is the AUTO_INCREMENT column attribute, which instructs MySQL to automatically use the next available value for a primary key.

  • @RobertJohnConcepcion http://stackoverflow.com/questions/611340/how-can-i-set-autoincrement-format-to-0001-in-mysql – Jonathan Kuhn Aug 23 '12 at 02:59
  • @Robert John Concepcion: don't mix the data and its presentation – zerkms Aug 23 '12 at 03:02
  • UPDATE `sampledb` SET `column1` = 'auto_increment' WHERE `id` ='$id' ei? this is posible? – Robert John Concepcion Aug 23 '12 at 03:06
  • $sql2 = mysql_query("select MAX(column1) FROM sampledb"); $iii=mysql_fetch_row($sql2); echo max($iii); $new = 1+max($iii); echo " $new"; mynext problem is, for example the highest # in my db is 000002, then the formula $new = 1+max($iii); ($new=000002+1), why the answer is 3 not 000003.. pls help me to do the format 000003.. plszzz Please be sure to answer the question. Provide details and share your research! http://php.net/manual/en/function.max.php – Robert John Concepcion Aug 23 '12 at 03:51