查看文件: test_rand.php
大小: 1.82 KB
类型: application/octet-stream
<?php require_once('../Connections/BE2.php'); ?> <? function ge10($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } function ge2($length = 2) { $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } function ge5($length = 5) { $characters = '0123456789'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } mysql_select_db($database_BE2, $BE2); $query_Rt2 = "SELECT * FROM member WHERE 1 order by mem_auto"; $Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error()); $row_Rt2 = mysql_fetch_assoc($Rt2); $totalRows_Rt2 = mysql_num_rows($Rt2); do { $k=1; $scode=""; while($k>0){ $scode = ge2().ge5(); mysql_select_db($database_BE2, $BE2); $q2= "SELECT * FROM member where scode='$scode' "; $Rq2 = mysql_query($q2, $BE2) or die(mysql_error()); $row_Rq2 = mysql_fetch_assoc($Rq2); $k = mysql_num_rows($Rq2); } mysql_free_result($Rq2); $up2 = sprintf("UPDATE member SET scode='%s' WHERE mem_auto='%s'",$scode,$row_Rt2['mem_auto']); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($up2, $BE2) or die(mysql_error()); } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); mysql_free_result($Rt2); ?>
保存
取消
返回文件列表