Re: Auto Incrementing in PHP

From: Date: Sun, 19 Jan 2003 16:15:59 +0000
Subject: Re: Auto Incrementing in PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-132182@lists.php.net to get a copy of this message
Thanks Guys I just needed a pointer. I decided to use the database and created two tables, one for invoice number and one for order number then defined a function to read the current number and the increment it. // GET AUTO NUMBER and creates the next one // uses the parameter tablename as $table function get_auto_number($table) { if(!$table) { echo "The Function get_auto_number requires the peramater 'tablename' to allow it to know which auto number you want.<br>"; exit; } $query = 'select number from '.$table; $result = mysql_query($query); if (!$result) { echo "Sorry there is a problem getting the auto_number from the table ".$table."<br>"; exit; } $current_number = mysql_fetch_row($result); global $auto_number; $auto_number = $current_number[0]; $query = "update ".$table." SET number = '".($auto_number +1)."'"; $result = mysql_query($query); } Simple when someone tells you what to do :o) Thanks and regards. "Don Mc Nair" <don@mcn.ie> wrote in message news:20030118204048.78225.qmail@pb1.pair.com... > Hi > > Is there a way for a php page to automatically increment a number and store > it every time the page is loaded. > > I want to generate an invoice number that goes up 1 everytime the HTML form > is sent to it. > > Thanks > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.435 / Virus Database: 244 - Release Date: 01/01/2003 > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.435 / Virus Database: 244 - Release Date: 02/01/2003

« previous php.general (#132182) next »