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 Link to comment https://forums.phpfreaks.com/topic/197846-trying-to-create-call-logging-system-need-number-generator/ 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... Link to comment https://forums.phpfreaks.com/topic/197846-trying-to-create-call-logging-system-need-number-generator/#findComment-1038253 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 Link to comment https://forums.phpfreaks.com/topic/197846-trying-to-create-call-logging-system-need-number-generator/#findComment-1038255 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 Link to comment https://forums.phpfreaks.com/topic/197846-trying-to-create-call-logging-system-need-number-generator/#findComment-1038262 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. Link to comment https://forums.phpfreaks.com/topic/197846-trying-to-create-call-logging-system-need-number-generator/#findComment-1038349 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.