Re: random code generator
Okay, never thought it would be that simple. The int(4) made it easier, having no results with zeros at the start of the code. Here's my fix, using the zen_rand() function.
Quote:
////
// Create a Custom Code. Length is 4 Digits starting from 1000
function zen_create_custom_code() {
global $db;
$code = zen_rand(1000,9999);
$good_result = 0;
while ($good_result == 0) {
$query = "select temp_id
from " . TABLE_TEMP . "
where temp_id = '" . $code . "'";
$rs = $db->Execute($query);
if ($rs->RecordCount() == 0) $good_result = 1;
}
return $code;
}