Return to Snippet

Revision: 40586
at February 4, 2011 03:04 by amyb


Initial Code
$unique = FALSE;

while ($unique == FALSE){

$ref = md5(date('r', time()) . rand(0,100)); 

$check_ref = mysql_query("SELECT ref FROM table_name WHERE ref = '$ref'");

if(mysql_num_rows($check_ref)==0){

$unique = TRUE;

}

}

Initial URL

                                

Initial Description

                                

Initial Title
Generate a random reference code and check it's unique

Initial Tags

                                

Initial Language
PHP