Page 1 of 1

i want to select max order and increament by 1

Posted: Fri Apr 25, 2008 5:06 am
by lerator
<?php
require "../conn.php";

$con = getConn();

if ($con){

mysql_select_db($db);


$sql=mysql_query("Select Max(refno) as num from Payment_infor");

$row = mysql_fetch_row($sql);
$newNum =$row['num']+1;

mysql_query("INSERT INTO Payment_infor (refno)
VALUES ('$newNum')");



}

?>

Re: i want to select max order and increament by 1

Posted: Fri Apr 25, 2008 5:18 am
by VladSun
[sql] INSERT INTO Payment_infor (refno) SELECT MAX(refno) + 1 FROM Payment_infor [/sql]