Hello List,
Trying to learn the right way to code this line.
Can anyone tell me if I am doing this the right way?
if $req_user_level == 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 ||
9 ? Guest || Regular User || Intl. User || Contractor ||
Employee || Sales || Investor || Human Resources ||
Hi,
did you mean something like this?
$level_names = array(Guest, Regular User, Intl. User,
Contractor, Employee,
Sales, Investor, Human Resources,
Administrator);
$user_level = $level_names[$req_user_level];
Regards,
Olavi Ivask
On Jan 25, 2010, at 9:13 PM, Karl
On Mon, 25 Jan 2010, Karl DeSaulniers wrote:
Hello List,
Trying to learn the right way to code this line.
Can anyone tell me if I am doing this the right way?
if $req_user_level == 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 ?
Guest || Regular User || Intl. User || Contractor || Employee
Hi,
$req_user_level is a MySql return result and I am trying to utilize
shortened code to evaluate whither $req_user_level == 0 || 1 || 2 ||
3 || 4 || 5 || 6 || 7 || 8 || 9, if it matches a number, return the
text associated with that number.
Guest || Regular User || Intl. User ||
I am trying to avoid doing this:
if ($req_user_level == 0) {
$req_user_level = Guest;
} else if ($req_user_level == 1) {
req_user_level = Regular User
}
etc..
Karl DeSaulniers
Design Drumm
http://designdrumm.com
Don't you like my solution?
Regards,
Olavi
On Jan 25, 2010, at 9:39 PM, Karl DeSaulniers wrote:
Hi,
$req_user_level is a MySql return result and I am trying to utilize
shortened code to evaluate whither $req_user_level == 0 || 1 || 2 ||
3 || 4 || 5 || 6 || 7 || 8 || 9, if it matches a
Thank you for this as well.
Question? What part is in_array playing?
Is it comparing $req_user_level to array()?
Because the text Guest, etc.. is not in $req_user_level on the
database.
In other words, is it checking the value of $req_user_level to see if
Guest is in it?
Karl
On Jan 25,
On Mon, 25 Jan 2010, Karl DeSaulniers wrote:
Thank you for this as well.
Question? What part is in_array playing?
Is it comparing $req_user_level to array()?
Because the text Guest, etc.. is not in $req_user_level on the database.
In other words, is it checking the value of $req_user_level to
Yes, $req_user_level is an int between 0 and 9.
Yes, the other code worked great.
Thank you for your response though.
That is definitely a good way to cross check.
Thanks again for your responses.
Best,
Karl
On Jan 25, 2010, at 2:24 PM, Peter Beckman wrote:
On Mon, 25 Jan 2010, Karl
On Saturday 19 December 2009 03:54:34 Karl DeSaulniers wrote:
Dont know if you found anything, but I ran accross this in on of my
other searches.
http://php.about.com/od/finishedphp1/p/day_redirect.htm
Karl
On Dec 18, 2009, at 10:10 AM, Philip Thompson wrote:
On Dec 15, 2009, at 6:02
Dont know if you found anything, but I ran accross this in on of my
other searches.
http://php.about.com/od/finishedphp1/p/day_redirect.htm
Karl
On Dec 18, 2009, at 10:10 AM, Philip Thompson wrote:
On Dec 15, 2009, at 6:02 PM, David McGlone wrote:
On Monday 14 December 2009 21:44:24
On Dec 15, 2009, at 6:02 PM, David McGlone wrote:
On Monday 14 December 2009 21:44:24 Chris wrote:
Chris wrote:
David McGlone wrote:
On Monday 14 December 2009 21:02:37 Chris wrote:
David McGlone wrote:
Hi everyone,
I've been lurking in the shadows on the list for quite some time and
On Monday 14 December 2009 21:44:24 Chris wrote:
Chris wrote:
David McGlone wrote:
On Monday 14 December 2009 21:02:37 Chris wrote:
David McGlone wrote:
Hi everyone,
I've been lurking in the shadows on the list for quite some time and
now
I'm in need of a little info or advise.
David McGlone wrote:
Hi everyone,
I've been lurking in the shadows on the list for quite some time and now I'm
in need of a little info or advise.
I'm looking for a way to grab a record out of a database on a certain day each
month and I'm wondering if this can be accomplished with just a
On Monday 14 December 2009 21:02:37 Chris wrote:
David McGlone wrote:
Hi everyone,
I've been lurking in the shadows on the list for quite some time and now
I'm in need of a little info or advise.
I'm looking for a way to grab a record out of a database on a certain day
each month
David McGlone wrote:
On Monday 14 December 2009 21:02:37 Chris wrote:
David McGlone wrote:
Hi everyone,
I've been lurking in the shadows on the list for quite some time and now
I'm in need of a little info or advise.
I'm looking for a way to grab a record out of a database on a certain day
Chris wrote:
David McGlone wrote:
On Monday 14 December 2009 21:02:37 Chris wrote:
David McGlone wrote:
Hi everyone,
I've been lurking in the shadows on the list for quite some time and
now
I'm in need of a little info or advise.
I'm looking for a way to grab a record out of a database on
If the past questions are 1,2,3,4:
Select * from `questions` where id not in (1,2,3,4) order by RAND();
Simcha Younger
-Original Message-
From: A. Joseph [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 26, 2008 7:38 PM
To: php-db@lists.php.net
Subject: [PHP-DB] Random content from
D.
Go to the manual at http://be2.php.net/manual/en/function.rand.php and
look at the User contributed notes further down the page. You'll find a
couple of solutions.
Whatever you do, you will presumably need to check the generated number
against the db to see if it is already in use and,
I know that true randomness only exists in nature. However, the
randomization in PHP is fairly good. I have only used it on fairly small
scales (i.e. Randomizing 200 quotes to give a random quote when people log
onto a page.)
For passwords I have always gone an easier route.
$password =
This is one I like to use jozef.
function generate_password($length = 10) {
$allowable_characters = abcdefghjkmnopqrstuvwxyz23456789;
$ps_len = strlen($allowable_characters);
mt_srand((double)microtime()*100);
$pass = ;
for($i = 0; $i $length; $i++) {
$pass .=
Frohwein [EMAIL PROTECTED]
To: 'J. Connolly' [EMAIL PROTECTED],'PHP list' php-db@lists.php.net
Subject: RE: [PHP-DB] Random Password problem
Date: Tue, 8 Mar 2005 11:51:59 -0800
This is one I like to use jozef.
function generate_password($length = 10) {
$allowable_characters
J. Connolly wrote:
I am using this php in order to create, store and send random passwords
to people who want to join my mailing list.
?php
function random_password () {
$seed = (integer) md5(microtime());
mt_srand($seed);
your seeding the randomizer with the value zero each time!
the
The robots that index the web.
Bastien gave me a web site to use for this.
Thanks.
Ron
- Original Message -
From: Zareef Ahmed [EMAIL PROTECTED]
To: Ron Piggott [EMAIL PROTECTED]
Cc: PHP DB php-db@lists.php.net
Sent: Saturday, March 05, 2005 11:56 AM
Subject: Re: [PHP-DB] Random
i use this function to generate a random 7 letter password...simple change
to make it 8
function change_password($id, $password)
{
//generate a random password
$pass = ;
$salt = abchefghjkmnpqrstuvwxyz0123456789;
srand((double)microtime()*100);
$i = 0;
while ($i = 7) {
$num =
On Sun, 23 Jan 2005 10:43:03 +0400, Radwan Aladdin
[EMAIL PROTECTED] wrote:
I wanted to know the best Random Function for PHP.. But please I don't want
duplications to happen at the same second.. because I receive many
customers..
For that purpose, mt_rand ( [int min, int max]) function is
See Below
On Sun, 2004-07-04 at 05:54, Ronald The Newbie Allen wrote:
Here is my code I keep on getting a Resource id #2 ..whatever that
meansany help would be appreciated!
html
head
titleTop Frame/title
/head
body bgcolor=#ff text=#00 link=#ff
Here is my code I keep on getting a Resource id #2 ..whatever
that
meansany help would be appreciated!
$music = mysql_query (Select * from $db_table ORDER BY RAND() Limit
1);
if(!$music) die(Query Failed.);
while($row = mysql_fetch_row($music))
print $music;
}
This is because
This recent thread from the mysql list explains a lot about the
problem.
http://lists.mysql.com/cgi-ez/ezmlm-cgi?1:mss:15034
hth,
Doug
On Sat, 1 Mar 2003 12:24:57 +0100, Frank Keessen wrote:
Hi All,
I'm trying to get a random record each time this script runs; Only it's giving me
everytime
/
---
-Original Message-
From: Hutchins, Richard [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 17, 2002 9:26 AM
To: 'Bruce Levick'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] random rows...what about tables
I think it's because mysql_list_tables returns
On Tuesday 17 December 2002 18:46, Bruce Levick wrote:
Bruce Levick - VivamotionI was curious as to what is the best way to select
a random row from a table in my database.
I have currently five rows and will be expanding on that as well. I have
tried this code.
On Tuesday 17 December 2002 21:38, Bruce Levick wrote:
Bruce Levick - Vivamotion
Been searching for an answer to selecting a random table and then a random
row within the selected table.
I have this code which successfully selects a random row within a hard
coded table. But just can't get
At 23:38 17-12-02 +1000, Bruce Levick wrote:
Bruce Levick - Vivamotion
Been searching for an answer to selecting a random table and then a random
row within the selected table.
I have this code which successfully selects a random row within a hard coded
table. But just can't get the random table
: Jason Wong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, December 17, 2002 11:48 PM
Subject: Re: [PHP-DB] random rows...what about tables
On Tuesday 17 December 2002 21:38, Bruce Levick wrote:
Bruce Levick - Vivamotion
Been searching for an answer to selecting a random table
9:19 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] random rows...what about tables
Sorry,
Have updated my script with a little help. Upon output i am
recieving this.
Warning: Argument to array_rand() has to be an array in
C:\WORKING\portfolio\vivamotion\site\php\request.php on line 51
On Tuesday 17 December 2002 22:18, Bruce Levick wrote:
Sorry,
Have updated my script with a little help. Upon output i am recieving this.
Warning: Argument to array_rand() has to be an array in
C:\WORKING\portfolio\vivamotion\site\php\request.php on line 51
OK, start from the basics.
I'm trying to make shops that sell virtual objects. They restock
once
every 15 minutes. This is all set up. The problem is, I would like
to
have objects in these shops with a random chance of being restocked.
My
idea is to store two numbers in the restock list: chance, and outof.
(For a
On Wednesday 05 June 2002 03:56, Natividad Castro wrote:
hi to all,
I have a drop down menu where users will select a word. After they submit
it, I will generate a code number where I want to display the first three
characters of the word they selected follow by Month and Date and three
are you just looking for a way to display 10 results per page? If yes then
you can just use LIMIT to limit your result to 10 .. So, for the first page,
you can do SELECT LIMIT 1, 10; and for the second page SELECT ...
LIMIT 11, 20 etc etc .
You can sure use ORDER BY with LIMIT to to sort
yea, i know how to display 10 results per page, but that doesnt work when
you want to do a ORDER BY rand() query.
Gurhan Ozen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
are you just looking for a way to display 10 results per page? If yes
then
you can just
could you perhaps do the select on the first page, then store the results in
a session (array) and just load different indexed portions of the resultset
each page?
only problem there is that you wouldn't get any refreshed results while
browsing those pages - but i don't know if this matters for
element in $seen... thus not allowing duplicates on a per
visit basis...
-Original Message-
From: Georgie Casey [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 13, 2002 4:11 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Random Selecting from mySQL
yea, i know how
On sön, 03 feb 2002, Chris Payne wrote:
Hi there everyone,
I need to generate a random number between 1 and 15 for insertion into a
DB, I can easily do the DB side of it but what is the best method for
quickly generating a random number between 1 and 15 (including 1 and 15
in the
Hi there,
That is absolutely PERFECT, thank you so much for that you are a lifesaver
:-)
Regards
Chris Payne
www.planetoxygene.com
On sön, 03 feb 2002, Chris Payne wrote:
Hi there everyone,
I need to generate a random number between 1 and 15 for insertion into a
DB, I can easily
At 25.09.2001 22:46, Saulius Jankauskas wrote:
Hello,
Can you give me a piece of code, where I could see, how to create random
written numbers and letters?
For example, I'd like to give my visitor temporary passwrord: BS0147. To
another HF0124 and so on...
How to generate it with PHP?
Sorry,
Try:
$result = mysql_db_query ($DBName,select * from Contacts order by rand()
LIMIT 0,5 );
As your first example had the '0' and then the '5' after the LIMIT clause, the second
didn't have
th any '0'.
Cheers.
Russ
On Fri, 31 Aug 2001 20:59:16 +0100 Seb Frost [EMAIL PROTECTED] wrote:
I
I was sure there was a syntax error in that SELECT statement, but
according tho the description at
http://www.mysql.com/doc/M/a/Mathematical_functions.html, that looks
right on to me. I know this doesn't help a lot, but at least you've had
a second set of eyes confirm that your code looks
according tho the description at
http://www.mysql.com/doc/M/a/Mathematical_functions.html, that looks
$result = mysql_db_query ($DBName,select * from Contacts order by rand()
LIMIT 5 );
Doesn't work at all. :(
What version of MySQL are you using? I remember something about ordering by
I know it's documented as rand() but you might want to try random() just in
case... I'm sure I read that somewhere
- seb
-Original Message-
From: John Hurleston [mailto:[EMAIL PROTECTED]]
Sent: 31 August 2001 19:18
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Random
I would like to
Adam,
I'm what I would call a novice to PHP and databases in general, however if I
had to do what you're doing, I might do the following...
Add a field to the table that contains your questions called displayed and
have it be an enum of Yes/No True/False, etc... In your script, you'd then
-Original Message-
From: Ryan Marrs [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 12, 2001 1:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Random Password Generation/MSSQL
Having an issue with this script, the generator works if I
just echo out the password, however when I
Hi Dan,
You need to call mt_srand() first to seed the random number generator. It's all
described here:
http://www.php.net/manual/en/function.mt-rand.php
Ken
* Dan Eskildsen [EMAIL PROTECTED] [010517 14:22]:
Newbie alert
Hi! Here is a piece of coding. It randomly choose
52 matches
Mail list logo