Jump to content

[SOLVED] random numbers to users in dbase


web_master

Recommended Posts

hi,

 

I got a table with users

 

table name: users

 

user_id

user_name

user_random

...

columns

 

<?php
if($_GET['random'] == "1") {


//Reload from database
$query_return=mysql_query("SELECT * FROM `user` ORDER BY `user_id`");

if(!$query_return) {
	echo mysql_error();
	exit;
}

while($request=mysql_fetch_array($query_return)) {

$rand_num = rand(100000000, 999999999); // random nrs

}




} //eng of GET
?>

 

So, every time when I get random ( $_GET['random'] == "1" ) I must to update in user table the user_random column for every user give a new random nr.

 

 

Link to comment
https://forums.phpfreaks.com/topic/59478-solved-random-numbers-to-users-in-dbase/
Share on other sites

I don't get what your asking, what do you require? Sorry

 

OK,

 

- I got for example 100 users

- TABLE users

- In users TABLE column RANDOM

 

So, every users can get one new RANDOM number if($_GET['random'] == "1")

 

example:

 

user_id = 1, random = 999999999

user_id = 2, random = 658435448

user_id = 3, random = 865435468 etc

 

on next if($_GET['random'] == "1")

 

user_id = 1, random = 798465484

user_id = 2, random = 654684354

user_id = 3, random = 154754687 etc

 

while($request=mysql_fetch_array($query_return)) {

$rand_num = rand(100000000, 999999999); // random nrs
             mysql_query("UPDATE `user` SET user_random = " . $rand_num . " WHERE user_id = " . $request['user_id'] . " LIMIT 1;");
}

 

Whats one way to do it, inefficient but it works.

while($request=mysql_fetch_array($query_return)) {

$rand_num = rand(100000000, 999999999); // random nrs
             mysql_query("UPDATE `user` SET user_random = " . $rand_num . " WHERE user_id = " . $request['user_id'] . " LIMIT 1;");
}

 

Whats one way to do it, inefficient but it works.

 

look at frost's

while($request=mysql_fetch_array($query_return)) {

$rand_num = rand(100000000, 999999999); // random nrs
             mysql_query("UPDATE `user` SET user_random = " . $rand_num . " WHERE user_id = " . $request['user_id'] . " LIMIT 1;");
}

 

Whats one way to do it, inefficient but it works.

 

THATS IT!!!!!!!!!!! ITS WORK!!!!! Thanks!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.