leachus2002 Posted April 7, 2010 Share Posted April 7, 2010 Hi All, I am currently trying to create a web based call logging system, based on a PHP front end and a MSSQL back end. I want to be able to grab the next number in a sequence so that when calls are logged, they are given a reference number. I have throught about using the random number generator in PHP, but there is a slight chance that I will get the same number twice. Is there a way that PHP can read, maybe from a table and use the next available number where a row is not populated? Many Thanks Matt Quote Link to comment Share on other sites More sharing options...
Deoctor Posted April 7, 2010 Share Posted April 7, 2010 sorry to tell u but i cannot understand what u are asking.. if u want to check the rand number <?php for ($i=1;$i<=1000;$i++) { $arr = range('a','z'); $arr1=range('',''); shuffle($arr); echo implode("", $arr);echo "<br>"; } ?> the odds of getting the same value are astronomical in this one... Quote Link to comment Share on other sites More sharing options...
leachus2002 Posted April 7, 2010 Author Share Posted April 7, 2010 Hi, Apoligies for not making myself clear. What I would like is for when a user is logging a call, then PHP assigns a call number to that call - for example 0001 - but when the next user logs a call, it assigns the next number, 0002 and so on and so on. Does that make sense? Thanks Matt Quote Link to comment Share on other sites More sharing options...
Deoctor Posted April 7, 2010 Share Posted April 7, 2010 i hope this is what u are looking for http://php.net/manual/en/function.mysql-insert-id.php Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 7, 2010 Share Posted April 7, 2010 Why not just let the (primary key) id field auto increment number serve as the reference number? Surely MS-Sql has a way to retrieve the id of the last inserted row similar to MySQL's mysql_insert_id. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.