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
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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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