Re: Help with a script

From: Date: Thu, 07 Dec 2000 21:50:32 +0000
Subject: Re: Help with a script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-29219@lists.php.net to get a copy of this message
Hello Phillip, Thursday, December 07, 2000, 1:29:09 PM, you wrote: PSB> Greetings all, PSB> I am having confusion about how to do something in the easiest bit of code. PSB> I can figure out how to do this I think, but the ideas I have involve allot PSB> of code. I am looking for something shorter that will also help me learn. PSB> Okay I have a table with some values like PSB> values PSB> id value PSB> 1 1400 PSB> 2 1200 PSB> 3 1100 PSB> 4 1000 PSB> Now I have a record in another table that has a user_value and a standing PSB> column. PSB> user PSB> id standing user_value PSB> 1 1 1456 PSB> 2 4 1054 PSB> 3 2 1321 PSB> The user_value changes allot based on input from the user. PSB> okay a user updates his user_value column. I want a script/query that will PSB> query the values table. Compare the values column to the user_values column PSB> and then sets the users standing based on the value. PSB> So for example. PSB> User 2 adds 50 to his user_value column for 1104. Query will see the value is >>1100 but <1200. So the standing of 3 is assigned to the user. Hmm you basically have it written .. <pseudo code> select uservalue from usertable where userid=2 uservalue += 50 update usertable set uservalue=uservalue where userid=2 select valueid from values where value_max >= uservalue and value_min <= uservalue update usertable set userstanding=valueid where userid = 2 You will notice that I have made one modification to your scheme. For the standing codes I have a min and max value for each code. I have always found this to be a better way to go. The reason for this is the amount time it might take to parse a table for the right bucket to fall into. Hope this helps -- DSig David Tod Sigafoos mailto:dsig@teleport.com Using 'The Bat' 1.48 Beta/8 ````` ( O O ) _______oOOo__( )__oOOo_______

« previous php.general (#29219) next »