[program-l] Re: php logic

  • From: "Bryan Schulz" <b.schulz@xxxxxxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Sun, 15 Jun 2014 12:20:20 -0500

hi,

the columns are in order according to real races that happen during a season labled race1, race2, etc but the values are not in order from high to low.

thanks, i was planning to read more about slice.
in the parens, does the number 2 slice two values from the beginning or the end?
Bryan Schulz

----- Original Message ----- From: "Parham Doustdar" <parham90@xxxxxxxxx>
To: <program-l@xxxxxxxxxxxxx>
Sent: Sunday, June 15, 2014 9:02 AM
Subject: [program-l] Re: php logic


Hi,

This doesn't really make sense. You have 10 columns. Are they sorted? How do you know what field each value goes to?

Popping is not really what you're looking for as you already know how many values, exactly, you need. You should slice the array:

$values = array_slice($values, 2, 8);

You can then use array_reduce() to add up every single value in the array.

Of course, I've assumed you've got them into an array and sorted them first. Be careful as sort and rsort sort your values like [1, 10, 2, 3], instead of [1, 2, 3, 10] under certain circumstances. If you want what's called natural (or human) sorting, use natsort.

If you still need more help, let us know.
On 6/15/2014 6:20 PM, Bryan Schulz wrote:
hi,

sorry it was a bit fuzzy.
each value is in a separate field in the same record.
i have ten values and want to throw out the two lowest values then total the remaining eight values.
jacobs idea is what i started thinking last night.
from reading, it seems that the php rsort function will put the lowest number at the end and php pop will delete the lowest value.

i could capture the remaining values and do that again or there may be another way to do the entire task in one step.
Bryan Schulz


----- Original Message ----- From: "Jacob Kruger" <jacob@xxxxxxxxxxxxx>
To: <program-l@xxxxxxxxxxxxx>
Sent: Sunday, June 15, 2014 6:40 AM
Subject: [program-l] Re: php logic


Well, then you might do best to pull them out of the database, load them into a PHP array, where you can sort them, and then use the lowest two values from there to generate an SQL statement to clear the values from the record..?

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

----- Original Message ----- From: "Bryan Schulz" <b.schulz@xxxxxxxxxxxxx>
To: <program-l@xxxxxxxxxxxxx>
Sent: Saturday, 14 June, 2014 10:28 PM
Subject: [program-l] Re: php logic


hi,

close, they are a series of scores all in the same record for a player
Bryan Schulz


----- Original Message ----- From: "Jacob Kruger" <jacob@xxxxxxxxxxxxx>
To: <program-l@xxxxxxxxxxxxx>
Sent: Saturday, June 14, 2014 6:13 AM
Subject: [program-l] Re: php logic


If those are numbers in a specific field - field1 - in a mysql table, then something like the following SQL statement might select/delete the relevant two rows:

delete from tbl_one where id in (select id from tbl_one order by i_field1 desc limit 2);

And, haven't tested that, but, think it's roundabout right - might be minor syntax issues.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

----- Original Message ----- From: "Bryan Schulz" <b.schulz@xxxxxxxxxxxxx>
To: <program-l@xxxxxxxxxxxxx>
Sent: Saturday, 14 June, 2014 7:56 AM
Subject: [program-l] php logic


hi,

could someone provide pseudo thoughts of how to throw away two values from a mysql table using php?

a sample would be these numbers:
542, 567, 452, 624, 584, 472, 645.

how would you throw away the low values of 452 and 472?

thanks,
Bryan Schulz

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq


** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq


** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq


** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: