i want to select max order and increament by 1

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lerator
Forum Newbie
Posts: 3
Joined: Fri Apr 25, 2008 4:57 am

i want to select max order and increament by 1

Post 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')");



}

?>
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

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

Post by VladSun »

[sql] INSERT INTO Payment_infor (refno) SELECT MAX(refno) + 1 FROM Payment_infor [/sql]
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply