php rand() question

  • jamesbond
  • Novice
  • Novice
  • No Avatar
  • Joined: Aug 22, 2011
  • Posts: 19
  • Status: Offline

Post September 22nd, 2011, 12:57 am

i have a form asking a user for a number and i want a rand number generated that would be = to or less the users numbers. I know the rand(min,max) works but what if i want max to be a number chosen on a form ? how would i code that. I tried entering the variable like this rand(0,$variable) but that does not work.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 22nd, 2011, 12:57 am

  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post September 22nd, 2011, 12:21 pm

*sigh*

You haven't given us any information to help you do what you want to do. What language are you working in? What code do you have so far? What exactly "does not work"?
The Beer Monocle. Classy.
  • jamesbond
  • Novice
  • Novice
  • No Avatar
  • Joined: Aug 22, 2011
  • Posts: 19
  • Status: Offline

Post September 22nd, 2011, 8:52 pm

its php and i fixed it already. it was just a problem using rand(). it was a problem using a variable as max and the fix was a spelling error (i know i should know better but it was a long day)

ps. It says in my topic php rand() question
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post September 26th, 2011, 10:14 am

For future reference, simply having 'php' in your topic title doesn't provide any context. You could be running the PHP on page-load, via AJAX, etc. Without seeing code, we can't just guess the problem.

Glad you got it figured out.
The Beer Monocle. Classy.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 216 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.