Solved

Random num

Posted on 2004-10-17
3
261 Views
Last Modified: 2006-11-17
I am trying to create a ID like a number which should be different each time I click a button. How do I make the number different or change to a random number each time I hit the button....?



Moiz
0
Comment
Question by:Moizsaif123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 40 total points
ID: 12334470
A usual technique is to use md5/uniqid/rand combination:

$id = md5(uniqid(rand()));
0
 
LVL 12

Assisted Solution

by:minichicken
minichicken earned 30 total points
ID: 12334514
Hi

If you just want numbers, you can just use
rand([min], [max]);

if you want better random numbers you can use
mt_rand ( [int min, int max])

more info:
http://za2.php.net/rand
http://za2.php.net/mt_rand
0
 
LVL 4

Assisted Solution

by:Tagor
Tagor earned 30 total points
ID: 12334648
rand(1,9) will create a random number between between 0 and 10.

You could use it this way: $number = "".rand(1,9)."".rand(1,9)."".rand(1,9)."".rand(1,9)."".rand(1,9)."";
This will create a random number that is 5 digits long.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question