Jump to content

dharm

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Everything posted by dharm

  1. Thanks for your help everyone.. autoincrementing is an option I considered but wouldn’t it be less efficient as I wouldn’t be able to replace expired members? By using a checked random number it should save disk space and ID numbers.
  2. Hi, im a newbe to php. I want to create a six digit random number as an ID but would like to also check if its not been already used within the database. Here is the code I have so far.. [code]     $chars_for_actnum = array ("1","2","3","4","5","6","7","8","9","0");         for ($i = 1; $i <= 6; $i++) {             $actnum = $actnum . $chars_for_actnum[mt_rand (0, count ($chars_for_actnum)-1)];                          //make a loop so we can check the database if ID has already been taken. if it has we will genarate another ID. $query = "Select * from ".$DBprefix."client_info where id='$actnum'"; $result = mysql_query($query); if ($row = mysql_fetch_array($result)){ if  ($row["id"] == $actnum)         }     }[/code] Any help will be much appreciated. Thx [b]EDITED BY WILDTEEN88: PLEASE USE THE CODE TAGS WHEN POSTING CODE, THANK YOU[/b]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.