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.
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 mysql query or
would I
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
I`m creating a small application that let users take test online, the
user will login and visit the test page, questions and answers are
stored in MySql database,
i want to display each randomly without repeating.
test must to completed between some specific amount of time or else
the
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 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);
$password = mt_rand(1,);
$password = substr(md5($password), 3,9);
return $password;
PROTECTED]
562.924.4454 (office)
562.924.4075 (fax)
continuing the struggle against bad code
*/
?
From: J. Connolly [EMAIL PROTECTED]
Date: Tue, 08 Mar 2005 14:41:11 -0500
To: PHP list php-db@lists.php.net
Subject: [PHP-DB] Random Password problem
I am using this php in order to create
.= $allowable_characters[mt_rand(0,$ps_len-1)];
}
return $pass;
}
Its been working well for me for sometime.
-Wendell Frohwein
-Original Message-
From: J. Connolly [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 08, 2005 11:41 AM
To: PHP list
Subject: [PHP-DB] Random Password problem
I am using this php
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
Is there a way of generating an 8 character random string in PHP?
Is there a way to ignore UPPER and lower case when you are using the SELECT
command to find a record in the mySQL table?
I know this isn't an HTML forum ... I have one more question which is more
HTML in nature. I don't want some
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
PROTECTED]
To: PHP DB php-db@lists.php.net
Subject: [PHP-DB] Random Character String
Date: Sat, 5 Mar 2005 09:38:35 -0500
Is there a way of generating an 8 character random string in PHP?
Is there a way to ignore UPPER and lower case when you are using the SELECT
command to find a record in the mySQL
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
Hi all!
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..
And also how can I add [EMAIL PROTECTED], whic abc is a variable... and
localhost.com is a static text??
So I only request from the
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!
html
head
titleTop Frame/title
/head
body bgcolor=#ff text=#00 link=#ff vlink=#800080
alink=#ff
EMBED SRC= autostart=true hidden=true loop=true volume=100%
?
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
Hi All,
I'm trying to get a random record each time this script runs; Only it's giving me
everytime the first record back.. No random at all..
// generate and execute query
$query = SELECT stedenid, naamstad, stadomschrijvk FROM steden ORDER BY RAND() LIMIT
1;
$result = mysql_query($query) or
/
---
-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
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.
//retrieve
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.
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 working.
?php
//trying to select all tables
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
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
can someone help me to generate a random records from the database?
eg,
rec 1 john doe
rec 2 jay williams
rec 3 anie boo
random results:
rec 2 jay williams
rec 1 john doe
rec 3 anie boo
.
TIA'
zham
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit:
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
number that will be generating randomly.
I don't have any problem
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
I know how to use the ORDER BY rand() command on the end of queries to
randomize selection, but that's no good when you want to only display 10
results per page. The next page the user chooses, randomizes again and could
show duplicate fields and not at all show other fields.
Does anyone know a
the results for a
given criteria ..
Gurhan
-Original Message-
From: Georgie Casey [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 13, 2002 2:00 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP-DB] Random Selecting from mySQL
I know how to use the ORDER BY rand() command
--
From: Georgie Casey [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 13, 2002 2:00 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP-DB] Random Selecting from mySQL
I know how to use the ORDER BY rand() command on the end of queries to
randomize selection, but that's no good when
for you or not.
HTH
Beau
// -Original Message-
// From: Georgie Casey [mailto:[EMAIL PROTECTED]]
// Sent: Thursday, 14 March 2002 3:00 AM
// To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
// Subject: [PHP-DB] Random Selecting from mySQL
//
//
// I know how to use the ORDER BY rand() command
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
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 equation)?
Thanks for all your help.
Regards
Chris
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
Hi,
I'm trying to pull a random row from my database and display the contents.
I know that the code:
SELECT * FROM TABLENAME WHERE RAND() LIMIT 1
should work.
However, there are 19 rows in the database and only the first row ever shows
up.
Is there a way to do this to ensure uniqueness?
The
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, if I didn;t explained clearly what I want.
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,
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
I would like to get the first 5 random entries out of my mysql database,
what would be the correct SELECT option?
I adjusted this line
$result = mysql_db_query ($DBName,select * from Contacts LIMIT 0,5 );
which works correctly. :)
$result = mysql_db_query ($DBName,select * from Contacts order
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
I'm having a bit of trouble creating a random question selector. I'm using PHP 4.0.6
and MySQL 3.23.36 on Windows 98 SE.
I've tried several different solutions, but none work at all.
What i need to do is select 10 questions from a database (db: vpt, table: questions),
and make sure that the
/xtremist
- Original Message -
From: Adam Lundrigan [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, July 31, 2001 2:32 PM
Subject: [PHP-DB] Random question selection in PHP w/ MySQL backend.
I'm having a bit of trouble creating a random question selector. I'm using
PHP 4.0.6 and MySQL
Having an issue with this script, the generator works if I just echo out the
password, however when I attempt to update the table, it times-out in IIS.
I've bumped the IIS Timeout up to over 20 minutes, and it still times out.
This is on a database with approximately 29,000 entries. Any ideas?
-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
Newbie alert
Hi! Here is a piece of coding. It randomly choose between four options to
display on my homepage. The problem is that it doesn't seem to be that
random - rather biased. The last option $message[3] is displayed 9 out of
10 times. Any suggestions?
script language=php
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
72 matches
Mail list logo