473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Pseudo-random month based selection

This isn't necessarily specific to PHP, but I am trying to figure out a way to pseudo-randomly generate a number based on the month. To clarify a little, I want the number returned to stay the same for the entire month, and then change to another "random" number for the next month. There would also need to be a ceiling on how big the number could be. I can't think of a way to write this, is there anyone able to help?
Nov 15 '07 #1
2 1488
Atli
5,058 Expert 4TB
Hi.

You can use the mt_rand function to generate a random number. You can even specify the lowest and highest limits.

As to using a single random number for the entire month. You will obviously have to store this number somewhere, where it can be read by your code. I would probably use a Database, like MySQL.
You would simply have to have a field for your random number, and a date field for the month it represents. If there is not a field for the current month, you use the function to generate a new number and add it for the current month.
Nov 16 '07 #2
pbmods
5,821 Expert 4TB
Heya, megahurtz.

Expand|Select|Wrap|Line Numbers
  1. srand(date('m'));
  2.  
Nov 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Andrew Thompson | last post by:
I would like to create a menu that uses the 'active' pseudo-class to highlight the current page, but I cannot get it to work. The URL http://www.lensescapes.com/tst/nav/1.jsp shows the attempts...
4
by: Stephen Poley | last post by:
The issue of the focus pseudo-class came up a few weeks ago, and I finally got around to trying it out (better late than never ...) The recommended order given for the pseudo-classes is link,...
8
by: Kerberos | last post by:
As you might know, IE doesn't support the :hover pseudo-class on every tag (just the "a" tag AFAIK) Is there a simple JavaScript that would solve the problem? I have images that have a light blue...
1
by: Steven T. Hatton | last post by:
ISO/IEC 14882:2003: "5.2.4 Pseudo destructor call The use of a pseudo-destructor-name after a dot . or arrow -> operator represents the destructor for the non-class...
6
by: Fungii | last post by:
Hello, I have a stylesheet that sets p:first-letter to a certain size and colour. I was playing around with Javascript to change paragraph stylesheets using an array like this: var paras =...
1
by: rudderstick | last post by:
Hi there all, I have an interesting problem.... I work for a company that develops software for the building industry and would like to distribute one of our software products via the web. ...
37
by: pochartrand | last post by:
Hello, Is there a way to manipulate or at least read the pseudo-class of an element ? I know the style attribute can be accessed and gives the CSS properties for a particular element....
3
by: yawnmoth | last post by:
I've seen a few webpages that use the javascript pseudo-protocol with event handlers. eg. <input onkeyup="javascript: ..." /> Correct me if I'm wrong, but isn't onkeyup always supposed to be...
0
by: Kevin Frey | last post by:
WebControl contains properties such as ControlStyle and Style for controlling the style of a web-control. In particular the Style property is a CssStyleCollection that simply comprises key-value...
3
by: bytehunter | last post by:
Hello, I hope this is the best place to ask my question. I was wondering if there was such a thing as a pseudo terminal in Windows. For those unfamiliar, in Linux/Unix one can create a pseudo...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.