takn25 Posted April 12, 2011 Share Posted April 12, 2011 Hi, I have a row called code in mysql data base now what I want to do is something like this $rand=rand(1111,9999); $code=mysql_query("UPDATE member SET code='$rand' WHERE clan_id='1'"); At the moment its updating the code row with the same random number. What I want to achieve is a unique number for each member. For instance Currently if the $rand=1289 lets suppose Every code row will become 1289 I want the code rows to be different to each other. I tried a few things up my sleeve but no luck. How can i do this? thanks any help much appreciated. Link to comment https://forums.phpfreaks.com/topic/233493-updating-multiple-rows-with-different-values/ Share on other sites More sharing options...
QuickOldCar Posted April 12, 2011 Share Posted April 12, 2011 How about adding a md5 along with the random number in a larger range. A simple example <?php $member = $_POST['member']; if(!isset($_POST['member']) || $member == ''){ echo "Insert a member name"; } else { $rand_number = rand(1111,50000); $merge_code = md5("$member$rand_number"); echo $merge_code; } ?> <html> <body> <form action="" method="post"> Member: <input type="text" name="member" /> <input type="submit" name="Make Code"/> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/233493-updating-multiple-rows-with-different-values/#findComment-1200640 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.