RE: [PHP] Sorting Help

2012-04-11 Thread admin
-Original Message- From: Floyd Resler [mailto:fres...@adex-intl.com] Sent: Wednesday, April 11, 2012 11:26 AM To: PHP Subject: [PHP] Sorting Help I need to sort the following array: { [Smith, Bob]=array(137.5,125.5), [Jones, Robert]=array(132.7,128.2) } The array needs

RE: [PHP] Sorting Help

2012-04-11 Thread admin
-Original Message- From: Floyd Resler [mailto:fres...@adex-intl.com] Sent: Wednesday, April 11, 2012 11:26 AM To: PHP Subject: [PHP] Sorting Help I need to sort the following array: { [Smith, Bob]=array(137.5,125.5), [Jones, Robert]=array(132.7,128.2) } The array needs

Re: [PHP] Sorting Help

2012-04-11 Thread Floyd Resler
On Apr 11, 2012, at 1:11 PM, admin wrote: -Original Message- From: Floyd Resler [mailto:fres...@adex-intl.com] Sent: Wednesday, April 11, 2012 11:26 AM To: PHP Subject: [PHP] Sorting Help I need to sort the following array: { [Smith, Bob]=array(137.5,125.5),

Re: [PHP] Sorting Help

2012-04-11 Thread Stuart Dallas
On 11 Apr 2012, at 16:26, Floyd Resler wrote: I need to sort the following array: { [Smith, Bob]=array(137.5,125.5), [Jones, Robert]=array(132.7,128.2) } The array needs to be sorted by the first number (i.e. 137.5) and then the second in descending order. I looked at

Re: [PHP] Sorting Help

2012-04-11 Thread Bastien
Bastien Koert On 2012-04-11, at 2:18 PM, Floyd Resler fres...@adex-intl.com wrote: On Apr 11, 2012, at 1:11 PM, admin wrote: -Original Message- From: Floyd Resler [mailto:fres...@adex-intl.com] Sent: Wednesday, April 11, 2012 11:26 AM To: PHP Subject: [PHP] Sorting Help

Re: [PHP] Sorting an array

2011-03-01 Thread Jim Lucas
On 2/28/2011 7:52 PM, Ron Piggott wrote: I need help to know how to sort the words / phrases in my array. Variable name: $words_used print_r( $words_used ); Current output: Array ( [187] = Sin [249] = Punished [98] = Sanctuary [596] = Sing [362] = Anointing Oil ) Desired result:

Re: [PHP] Sorting an array

2011-02-28 Thread Simon J Welsh
On 1/03/2011, at 4:52 PM, Ron Piggott wrote: I need help to know how to sort the words / phrases in my array. Variable name: $words_used print_r( $words_used ); Current output: Array ( [187] = Sin [249] = Punished [98] = Sanctuary [596] = Sing [362] = Anointing Oil ) Desired result:

Re: [PHP] Sorting an array of sub-arrays based on a sub-array's key

2009-09-06 Thread Eddie Drapkin
On Sun, Sep 6, 2009 at 6:45 PM, James Colanninoja...@colannino.org wrote: Hey everyone.  I have an array that looks like this: $main_array[0] = array('key1' = 'vala'); $main_array[1] = array('key1' = 'valb'); etc. I want to sort the main array based on the value of key1 for each sub-array.

Re: [PHP] Sorting an array of sub-arrays based on a sub-array's key

2009-09-06 Thread James Colannino
Eddie Drapkin wrote: http://us3.php.net/uasort Exactly what I was looking for. Thanks. James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Sorting mySQL query - one order from multiple fields

2009-07-26 Thread George Langley
In case anyone else was wondering, the command to use is COALESCE() as in: $theQuery = mysql_query(select variousFields from theTable where date = '$currDate' ORDER BY COALESCE(rotime2,rotime1,time)); COALESCE() will use one of the variables, being the one it finds a value for first,

Re: [PHP] Sorting times (SOLVED)

2009-05-16 Thread German Geek
Just a draft i thought should not go unnoticed on the list :-) just cleaning up. OK, How about a super efficient soln where each string is only converted once and a fast sorting algorithm is used: ?php function time_sort($a, $b) { static $now = time(); if (strtotime($a, $now) ==

Re: [PHP] Sorting times (SOLVED)

2009-02-15 Thread tedd
At 9:31 PM -0600 2/14/09, Shawn McKenzie wrote: Yeah, hif I had known that you wanted a function where you loop through your array twice, that would have done it. Bravo. Shawn: I don't see another way. You go through the array converting string to time (seconds), sort, and then convert

Re: [PHP] Sorting times (SOLVED)

2009-02-15 Thread Shawn McKenzie
tedd wrote: At 9:31 PM -0600 2/14/09, Shawn McKenzie wrote: Yeah, hif I had known that you wanted a function where you loop through your array twice, that would have done it. Bravo. Shawn: I don't see another way. You go through the array converting string to time (seconds), sort, and

Re: [PHP] Sorting times

2009-02-14 Thread John Corry
1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com On Feb 14, 2009, at 4:07 PM, tedd wrote: Hi gang: Anyone

Re: [PHP] Sorting times

2009-02-14 Thread Shawn McKenzie
John Corry wrote: 1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com On Feb 14, 2009, at 4:07 PM, tedd

Re: [PHP] Sorting times (SOLVED)

2009-02-14 Thread tedd
At 4:15 PM -0500 2/14/09, John Corry wrote: 1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com John: Bingo -- that

Re: [PHP] Sorting times (SOLVED)

2009-02-14 Thread Shawn McKenzie
tedd wrote: At 4:15 PM -0500 2/14/09, John Corry wrote: 1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com John:

Re: [PHP] Sorting Arrays

2008-08-22 Thread Micah Gersten
I believe you'll need a custom sorting function for this. http://us.php.net/usort Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Tom Shaw wrote: I'm having a problem sorting my array and wondered if anybody had experience sorting arrays by their values.

Re: [PHP] Sorting Arrays

2008-08-22 Thread Ashley Sheridan
Yeah, a bubble sorting algorithm should fix it, as it essentially only a very simple sort required. Ash www.ashleysheridan.co.uk ---BeginMessage--- I believe you'll need a custom sorting function for this. http://us.php.net/usort Thank you, Micah Gersten onShore Networks Internal Developer

Re: [PHP] Sorting Arrays

2008-08-22 Thread Robert Cummings
message attachment, Forwarded message - Re: [PHP] Sorting Arrays Forwarded Message From: Micah Gersten [EMAIL PROTECTED] To: Tom Shaw [EMAIL PROTECTED] Cc: php-general@lists.php.net Subject: Re: [PHP] Sorting Arrays Date: Fri, 22 Aug 2008 14:18:53 -0500 I believe

Re: [PHP] Sorting Arrays

2008-08-22 Thread Micah Gersten
Robert Cummings wrote: On Fri, 2008-08-22 at 21:04 +0100, Ashley Sheridan wrote: Yeah, a bubble sorting algorithm should fix it, as it essentially only a very simple sort required. Why use bubble sort when you can use usort() function with an arbitrary handler? Cheers, Rob.

Re: [PHP] Sorting Arrays

2008-08-22 Thread Jim Lucas
Tom Shaw wrote: I'm having a problem sorting my array and wondered if anybody had experience sorting arrays by their values. What I need to do is resort the array below where the most expensive product shipping price starts at position zero no matter how big the array is. array(2) {

Re: [PHP] Sorting files in a directory

2007-08-09 Thread Chad Robinson
Steve Marquez wrote: I know this code does not work, but I was curious if someone can take a look and tell me what is wrong? Thank you so much. Re-indent your code properly. If you do it will look like: ?php $pattern = .html*|.php*; if (is_dir(files/)) { if ($dh = opendir(files/)) {

Re: [PHP] Sorting files in a directory

2007-08-08 Thread Chris
Steve Marquez wrote: Greetings, I have some code that opens a directory and displays the files. I want to display the files in Alphabetical order. I know this code does not work, but I was curious if someone can take a look and tell me what is wrong? Thank you so much. [ I hope the indenting

Re: [PHP] sorting via PHP or MySQL?

2007-05-13 Thread Richard Lynch
On Thu, May 10, 2007 1:00 pm, James Tu wrote: (I've cross posted at the MySQL list as well) Here's an example with a simple table: describe collection; +--+-+--+- +-++ | Field| Type

RE: [PHP] sorting via PHP or MySQL?

2007-05-10 Thread Brad Fuller
James Tu wrote: (I've cross posted at the MySQL list as well) Here's an example with a simple table: describe collection; +--+-+--+- +-++ Field| Type| Null | Key | Default

Re: [PHP] sorting via PHP or MySQL?

2007-05-10 Thread Robert Cummings
On Thu, 2007-05-10 at 14:00 -0400, James Tu wrote: (I've cross posted at the MySQL list as well) Here's an example with a simple table: describe collection; +--+-+--+- +-++ | Field| Type

Re: [PHP] sorting via PHP or MySQL?

2007-05-10 Thread Larry Garfield
A somewhat more extensible version of the 1 query method: http://www.garfieldtech.com/blog/php-group-by If you will only ever have 2 values there, then either method is probably fine. The php group by method (above) is more extensible if you're going to have a variable or arbitrary number of

Re: [PHP] sorting multi array

2007-04-25 Thread Frank Arensmeier
Jon, I would suggest that you should have a look at the function array_multisort. See the manual for details on what this function is capable of. //frank 25 apr 2007 kl. 01.58 skrev Jon Bennett: hi, I have the following array, which I need to sort by quantity... Array ( [2408] = Array

RE: [PHP] sorting multi array

2007-04-25 Thread Chris Boget
I have the following array, which I need to sort by quantity... I need to keep the indexes if poss. This may not be the most elegant solution. Let's call your array $origArray $tmpArray = array(); foreach( $origArray as $elKey = $elArray ) { $tmpArray[$elArray['quantity']] = $elKey; } if(

RE: [PHP] sorting multi array

2007-04-25 Thread Zoltán Németh
2007. 04. 25, szerda keltezéssel 11.39-kor Chris Boget ezt írta: I have the following array, which I need to sort by quantity... I need to keep the indexes if poss. This may not be the most elegant solution. Let's call your array $origArray $tmpArray = array(); foreach( $origArray as

Re: [PHP] sorting multi array

2007-04-25 Thread Chris Boget
this won't work if he has the same quantity for several keys, I think Yes, you are correct. If that is the case, then you would just need to change the following line $tmpArray[$elArray['quantity']] = $elKey; to $tmpArray[$elArray['quantity']][] = $elKey; then change logic in this loop:

Re: [PHP] sorting multi array

2007-04-25 Thread [EMAIL PROTECTED]
array_multisort accepts column arrays but here you try to sort row based arrays. try this: ? class ArrayUtility { /* Sorts an array by a member */ static private $sortMember; static function sortByMember($array, $member) { self::$sortMember = $member;

Re: [PHP] sorting multi array

2007-04-25 Thread Myron Turner
Jon Bennett wrote: hi, I have the following array, which I need to sort by quantity... Array ( [2408] = Array ( [name] = Havaianas Top Pink Crystal [size] = 5 (37/38) [quantity] = 4 ) [3388] = Array ( [name] = Havaianas

Re: [PHP] sorting multi array

2007-04-25 Thread Richard Lynch
Search the archives for multisort array and you should find this thread a few thousand times... On Tue, April 24, 2007 6:58 pm, Jon Bennett wrote: hi, I have the following array, which I need to sort by quantity... Array ( [2408] = Array ( [name] = Havaianas Top

Re: [PHP] Sorting a multidimensional array

2007-02-08 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-02-08 14:08:13 +: Hi all. I am building an online events directory and as part of the system users can search for events by date, category etc. The logic involved in finding events that match the user-entered dates works like so: 1. we create a range of

Re: [PHP] Sorting a multidimensional array

2007-02-08 Thread Dave Goodchild
Thanks for that - can't do that as all I know in the database is the start and end date for each event (so I don't have to create mapping tables and perform massive joins), the rest is handle dynamically. I think I can do it using usort, this seems to work, any comments? function compare($x,

Re: [PHP] Sorting a multidimensional array

2007-02-08 Thread Németh Zoltán
array_multisort? http://php.net/manual/en/function.array-multisort.php hope that helps Zoltán Németh On cs, 2007-02-08 at 14:08 +, Dave Goodchild wrote: Hi all. I am building an online events directory and as part of the system users can search for events by date, category etc. The

RE: [PHP] Sorting a multidimensional array

2007-02-08 Thread Edward Kay
How about this: http://uk.php.net/manual/en/function.array-multisort.php#53779 Edward -Original Message- From: Dave Goodchild [mailto:[EMAIL PROTECTED] Sent: 08 February 2007 14:30 To: Roman Neuhauser Cc: php-general@lists.php.net Subject: Re: [PHP] Sorting a multidimensional array

Re: [PHP] Sorting issue

2007-02-08 Thread tg-php
Paul's probably right.. putting the sorting values in a table would be eaiser to maintain. I don't know what I was thinking with the whole then you don't HAVE to create a table. Both ways work.. but especially if you think the positions may change, then it'll be tons easier to update if

Re: [PHP] Sorting issue

2007-02-07 Thread tg-php
Well, kind of ugly but you can do something like this: SELECT Position, CASE Position WHEN 'CEO' THEN 1 WHEN 'COO' THEN 2 WHEN 'CFO' THEN 3 WHEN 'HR' THEN 4 ELSE 99 END AS PositionSort FROM SomeTable ORDER BY PositionSort That way you're not creating a whole new table to store the sorting

Re: [PHP] Sorting issue

2007-02-07 Thread Paul Novitski
= = = Original message = = = I need to sort the results of a DB query based on the hierarchy of positions within an organization. Since they are not necessarily alphabetical, the best I can come up with is to assign a numerical value in a separate table to each position, and reference that to

Re: [PHP] Sorting multidimensional arrays

2006-11-16 Thread Robert Cummings
On Thu, 2006-11-16 at 15:28 +, Dave Goodchild wrote: Hi all. I have a multidimensional array here: Bums [name]= string(13) Tits And Bums [3]= string(19) The Pleasure [--SNIP--] ...which comprises a set of returned results for an events search - with the date computed dynamically and

Re: [PHP] Sorting multidimensional arrays

2006-11-16 Thread Dave Goodchild
Result. Cheers! On 11/16/06, Robert Cummings [EMAIL PROTECTED] wrote: On Thu, 2006-11-16 at 15:28 +, Dave Goodchild wrote: Hi all. I have a multidimensional array here: Bums [name]= string(13) Tits And Bums [3]= string(19) The Pleasure [--SNIP--] ...which comprises a set of returned

Re: [PHP] Sorting MySQL queries

2006-11-07 Thread Dotan Cohen
On 07/11/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: you really need to deal with this issue at the database design/data entry level. doing things on the sort to exclude (otherwise undefined) initial articles (as some have suggested) is very maintenance heavy as you have to update the sort

Re: [PHP] Sorting MySQL queries

2006-11-06 Thread tedd
At 3:13 PM +0200 11/5/06, Dotan Cohen wrote: I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in a database and being retrieved via php. I currently organize them alphabetically with SQL's ORDER BY ASC argument, however, if there is a

Re: [PHP] Sorting MySQL queries

2006-11-06 Thread Curt Zirzow
On 11/5/06, Roman Neuhauser [EMAIL PROTECTED] wrote: If you used PostgreSQL I'd suggest a functional index and ordering on the function... Does MySQL have anything like this? CREATE FUNCTION fn(TEXT) RETURNS TEXT IMMUTABLE STRICT LANGUAGE SQL AS $$ SELECT

Re: [PHP] Sorting MySQL queries

2006-11-06 Thread Richard Lynch
On Sun, November 5, 2006 7:13 am, Dotan Cohen wrote: I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in a database and being retrieved via php. I currently organize them alphabetically with SQL's ORDER BY ASC argument, however, if there is

Re: [PHP] Sorting MySQL queries

2006-11-06 Thread Dotan Cohen
On 06/11/06, Richard Lynch [EMAIL PROTECTED] wrote: On Sun, November 5, 2006 7:13 am, Dotan Cohen wrote: I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in a database and being retrieved via php. I currently organize them alphabetically

Re: [PHP] Sorting MySQL queries

2006-11-06 Thread Børge Holen
On Monday 06 November 2006 08:15, clive wrote: Current code: $query = SELECT subject FROM table ORDER BY subject asc; $result = mysql_query($query); I dont seen any php code to do any sorting,just a mysql query, perhaps a mysql list or maybe you should try doing it in php yourself first.

Re: [PHP] Sorting MySQL queries

2006-11-05 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-11-05 15:13:19 +0200: I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in a database and being retrieved via php. I currently organize them alphabetically with SQL's ORDER BY ASC argument, however, if there is a

Re: [PHP] Sorting MySQL queries

2006-11-05 Thread clive
Current code: $query = SELECT subject FROM table ORDER BY subject asc; $result = mysql_query($query); I dont seen any php code to do any sorting,just a mysql query, perhaps a mysql list or maybe you should try doing it in php yourself first. Not that I know the answer, but mysql does have

Re: [PHP] Sorting Multidimensional Array

2006-10-31 Thread Richard Lynch
On Tue, October 31, 2006 11:10 am, Keith Spiller wrote: RE: Sorting Multidimensional Array I'm trying to sort a multidimensional array. The data was taken from a mysql query: $myrow = mysql_fetch_row($result) { query[] = $myrow; } The purpose is to retrieve the table data and

Re: [PHP] Sorting Multidimensional Array

2006-10-31 Thread Keith Spiller
Subject: Re: [PHP] Sorting Multidimensional Array On Tue, October 31, 2006 11:10 am, Keith Spiller wrote: RE: Sorting Multidimensional Array I'm trying to sort a multidimensional array. The data was taken from a mysql query: $myrow = mysql_fetch_row($result) { query[] = $myrow

Re: [PHP] sorting array after array_count_values

2006-08-15 Thread Richard Lynch
On Tue, August 15, 2006 9:01 am, [EMAIL PROTECTED] wrote: I have an array of products $products $products = array_count_values($products); now I have an array where $key is product number and $value is how many times I have such a product in the array. I want to sort this new array that

Re: [PHP] sorting in array

2006-08-03 Thread Richard Lynch
For starters, the function is supposed to return 0 for countries that are equal. As it stands now, it's going to return 1 / -1 randomly based on which arg happens to be $a versus $b. That's bad. For some implementations of shuffle/sort routines, it will actually crash. I forget which

Re: [PHP] sorting in array

2006-07-31 Thread weetat
Hi , Doesn't work . Any ideas ? Thanks Peter Lauri wrote: function cmpcountry($a, $b) { $country1 = $a['country']; $country2 = $b['country']; if($country1=='') return 1; else return ($country1 $country2) ? -1 : 1; } -Original

Re: [PHP] sorting in array

2006-07-31 Thread Paul Novitski
At 10:31 PM 7/30/2006, weetat wrote: I have problem when doing usort() when 'country' = '', i would like to display records where country = '' last. Any ideas how to do that ? ... $arraytest= array( array ( 'country' = '', ) , array (

RE: [PHP] sorting in array

2006-07-31 Thread Paul Novitski
At 05:40 PM 7/30/2006, Peter Lauri wrote: function cmpcountry($a, $b) { $country1 = $a['country']; $country2 = $b['country']; if($country1=='') return 1; else return ($country1 $country2) ? -1 : 1; } Good call, Peter; my suggestion was

RE: [PHP] sorting in array

2006-07-31 Thread Paul Novitski
At 12:22 AM 7/31/2006, Paul Novitski wrote: I could make that last statement just a bit simpler: function cmpcountry($a, $b) { $country1 = ($a['country'] == '') ? zzz : $a['country']; $country2 = ($b['country'] == '') ? zzz : $b['country']; return ($country1

Re: [PHP] sorting in array

2006-07-31 Thread weetat
Thanks Paul, Very weird tried Peter's option, it doesn't work. Btw , how to sort by ascending ? Thanks Paul Novitski wrote: At 12:22 AM 7/31/2006, Paul Novitski wrote: I could make that last statement just a bit simpler: function cmpcountry($a, $b) { $country1 =

Re: [PHP] sorting in array

2006-07-31 Thread Paul Novitski
At 01:14 AM 7/31/2006, weetat wrote: Thanks Paul, Very weird tried Peter's option, it doesn't work. Btw , how to sort by ascending ? Please explain what you mean. The current script DOES sort ascending by country (except for the blank country fields which are placed at the end):

RE: [PHP] sorting in array

2006-07-31 Thread Peter Lauri
: Re: [PHP] sorting in array Thanks Paul, Very weird tried Peter's option, it doesn't work. Btw , how to sort by ascending ? Thanks Paul Novitski wrote: At 12:22 AM 7/31/2006, Paul Novitski wrote: I could make that last statement just a bit simpler: function cmpcountry($a, $b

RE: [PHP] sorting in array

2006-07-31 Thread Peter Lauri
@lists.php.net Subject: Re: [PHP] sorting in array At 10:31 PM 7/30/2006, weetat wrote: I have problem when doing usort() when 'country' = '', i would like to display records where country = '' last. Any ideas how to do that ? ... $arraytest= array( array

Re: [PHP] sorting in array

2006-07-31 Thread David Tulloh
weetat wrote: Hi all , I have array value as shown below, i have paste my test php code below: I have problem when doing usort() when 'country' = '', i would like to display records where country = '' last. Any ideas how to do that ? ... You might try searching the list's archive's.

RE: [PHP] sorting in array

2006-07-30 Thread Peter Lauri
function cmpcountry($a, $b) { $country1 = $a['country']; $country2 = $b['country']; if($country1=='') return 1; else return ($country1 $country2) ? -1 : 1; } -Original Message- From: weetat [mailto:[EMAIL PROTECTED] Sent: Monday, July

Re: [PHP] sorting array question

2006-07-26 Thread John Wells
On 7/26/06, Angelo Zanetti [EMAIL PROTECTED] wrote: Hi all, So they way I want to sort these rows is by total, totalPaid, totalUnpaid all descending. Hi Angelo, So the first question the list will ask is if the array of data is coming from a database. Because then you'd be urged to perform

Re: [PHP] sorting array question

2006-07-26 Thread Angelo Zanetti
hi guys, thanks for the replies! yes Melanie, you were correct the last example (i had an old version of the manual). seemed to do the trick =) Thanks to john as well for the reply. Angelo Melanie Maddix wrote: [snip] So they way I want to sort these rows is by total, totalPaid,

Re: [PHP] sorting troubles

2006-04-25 Thread Richard Lynch
On Sat, April 22, 2006 4:49 am, William Stokes wrote: I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by the letter an descending by the number. Can this be done? Like A20 B17 B16 C15

Re: [PHP] sorting troubles

2006-04-25 Thread William Stokes
Thanks for your input everyone! The easiest way to do this was ansding this to the SELECT clause: select col from DB order by substring(col, 1, 1) ASC, substring(col, 2) DESC Seems to work fine. -Will Richard Lynch [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] On Sat, April 22,

Re: [PHP] sorting troubles

2006-04-24 Thread Philip Thompson
On Apr 22, 2006, at 4:49 AM, William Stokes wrote: Hello, Any idea how to sort this? I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by the letter an descending by the number. Can this be

Re: [PHP] sorting troubles

2006-04-24 Thread Philip Thompson
On Apr 24, 2006, at 9:06 AM, Philip Thompson wrote: On Apr 22, 2006, at 4:49 AM, William Stokes wrote: Hello, Any idea how to sort this? I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by

Re: [PHP] sorting troubles

2006-04-23 Thread chris smith
I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by the letter an descending by the number. Can this be done? Like A20 B17 B16 C15 C14 D13 D12 Depending on how many records you have

Re: [PHP] sorting troubles

2006-04-23 Thread David Tulloh
William Stokes wrote: Hello, Any idea how to sort this? I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by the letter an descending by the number. Can this be done? PHP has the

Re: [PHP] sorting troubles

2006-04-22 Thread Peter Hoskin
See explode, http://www.php.net/explode $var = 'A20,B16,B17C14,C15,D13,D12'; $array = explode(',',$var); foreach ($array as $key = $value) { echo $value .\n; } William Stokes wrote: Hello, Any idea how to sort this? I have a column in DB that contains this kind of data,

Re: [PHP] sorting troubles

2006-04-22 Thread Peter Hoskin
hmm, should also see http://www.php.net/sort Peter Hoskin wrote: See explode, http://www.php.net/explode $var = 'A20,B16,B17C14,C15,D13,D12'; $array = explode(',',$var); foreach ($array as $key = $value) { echo $value .\n; } William Stokes wrote: Hello, Any idea how to sort

Re: [PHP] sorting troubles

2006-04-22 Thread Paul Novitski
At 02:49 AM 4/22/2006, William Stokes wrote: I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by the letter an descending by the number. Can this be done? Like A20 B17 B16 C15 C14 D13 D12

Re: [PHP] sorting troubles

2006-04-22 Thread Paul Novitski
At 03:43 AM 4/22/2006, I wrote: Then just do a reverse sort on $aTemp and you get: Z20 Y17 Y16 Then translate the letters back to their original values and you get: A20 B17 C16 Oops, I made a typo: that final value should have been B16, not

Re: [PHP] sorting dates with php

2005-12-21 Thread André Medeiros
You COULD sort them if the date was stored backwards, ie. Year/Month/Day On 12/21/05, Jim Moseby [EMAIL PROTECTED] wrote: Have a load of dates in the format DD/MM/YY. Thet are stored as a VARCHAR on a mysql DB. I need a way to sort them into order(most recent first) Using the

Re: [PHP] sorting dates with php

2005-12-21 Thread Chris Lott
On 12/21/05, Ross [EMAIL PROTECTED] wrote: Hi, Have a load of dates in the format DD/MM/YY. Thet are stored as a VARCHAR on a mysql DB. Couldn't you use cast() to cast the values first? Something like (untested): SELECT CAST(doc_date AS DATE) FROM papers ORDER BY doc_date DESC c -- PHP

Re: [PHP] Sorting users geographically...

2005-11-21 Thread David Grant
Hi Tony, I would think the first step would be to find a web service or dataset to convert a zip code to longitude/latitude. The formula for calculating distances from long/lat is available here: http://www.colorado.edu/geography/gcraft/warmup/aquifer/html/distance.html Cheers, David Grant

RE: [PHP] Sorting users geographically...

2005-11-21 Thread Jim Moseby
I'm helping a friend of mine build a matchmaking website, and we have a doozy of a problem to solve: What I need to do is two fold: #1 Collect whatever geographical information I need from each user to enable #2 #2 Be able to run query's to find people NEAR (geographically) another

RE: [PHP] Sorting users geographically...

2005-11-21 Thread Sandy Keathley
Does anyone know of any commercial or free implementations of this? Is it primarily a database problem or is their some way (computationally) to compute the probable proximity of two zip codes? There is a class called zipLocator. I think I found it at phpclasses.org. It uses a large

Re: [PHP] Sorting users geographically...

2005-11-21 Thread Marcus Bointon
On 21 Nov 2005, at 14:14, Tony Di Croce wrote: Does anyone know of any commercial or free implementations of this? Is it primarily a database problem or is their some way (computationally) to compute the probable proximity of two zip codes? All the suggested packages could be all you need,

Re: [PHP] Sorting with french characters

2005-06-23 Thread Richard Lynch
On Thu, June 23, 2005 7:37 am, Mathieu Dumoulin said: STR_REPLACE on all possible accents, i got over a thousand records from the database to parse in a fast way and there are at the very least 60 Odds are REALLY GOOD you can get the database to ORDER BY using your locale/language/charset of

Re: [PHP] sorting object props

2005-06-18 Thread Richard Lynch
On Fri, June 17, 2005 2:48 pm, D_C said: is there a way to sort the properties of an object by their name, much like sort works on arrays? i am getting back an object from a database query and want to list the resulting items in alpha order by field name... http://php.net/ksort Last time I

RE: [PHP] Sorting Objects in an array by object properties

2005-05-28 Thread Jared Williams
Hello list, I have an array which holds some objects. Each object represent elements from an email header in a given mailbox. Each object has properties like from, sendtime, subject etc. I want to sort the order of the objects in the array by their attribute sendtime in order to get

Re: [PHP] Sorting table columns dynamically on normalized MySQL tables

2005-04-22 Thread Richard Lynch
On Wed, April 20, 2005 5:53 am, Leif Gregory said: So joining on four tables isn't considered bad practice? No, it's great practice. The only thing to watch for is just how *BIG* will the number of tuples grow? If you can multiply together the number of rows in all four tables and come up with

Re: [PHP] Sorting table columns dynamically on normalized MySQL tables [LONG]

2005-04-20 Thread Leif Gregory
Hello Jay, Tuesday, April 19, 2005, 1:28:25 PM, you wrote: J Normalization has no effect on sort order where any DB is concerned. J Sort order is determined in the sort clause in the query. So if you want J to sort by location and you are using MySQL your ORDER BY clause should J be

Re: [PHP] Sorting table columns dynamically on normalized MySQL tables [LONG]

2005-04-20 Thread Chris Boget
The actual SELECT statement is as follows: $sqlCourses=SELECT * FROM . $tbl_courses . WHERE courseDate ' . date(Y-m-d) . ' ORDER BY . $orderBy . ASC; the $orderBy variable is set via $_GET['orderBy'] which is sent by the table headers as below: I'm curious why you aren't joining the

RE: [PHP] Sorting table columns dynamically on normalized MySQL tables [LONG]

2005-04-20 Thread Jay Blanchard
[snip] SELECT * FROM Course ORDER BY locationID ASC Now the ORDER BY can be any one of five things based on the variable passed by the hyperlink for the column they clicked on (location, course, date, category, and instructor [/snip] If you had a JOIN to the location table you could order by the

RE: [PHP] Sorting table columns dynamically on normalized MySQL tables [LONG]

2005-04-20 Thread Jay Blanchard
[snip] Sorry that this has degenerated into a MySQL question rather than PHP. I was originally looking for how people handled it in PHP. --- Actually it didn't degenerate, it was a SQL question all along. Unless you had a desire to build sortable arrays in PHP this type of sort should always be

Re: [PHP] Sorting table columns dynamically on normalized MySQL tables

2005-04-20 Thread Leif Gregory
Hello Kim, Tuesday, April 19, 2005, 6:44:58 PM, you wrote: K If you are still looking for tips and want to get K complicated/fancy, I have seen columns used called sort_order more K than a few times. This should not be too hard to maintain for K things like a few buildings, etc., where the lookup

Re: [PHP] Sorting table columns dynamically on normalized MySQL tables

2005-04-20 Thread Leif Gregory
Hello Richard, Tuesday, April 19, 2005, 9:12:14 PM, you wrote: R Just build a JOIN query and do one query. Doing a join on four tables is ok? (serious question, not being facetious). R No, it is *NOT* sorting on the ID number. I can definitely say it is sorting on locationID, categoryID, or

Re: [PHP] Sorting table columns dynamically on normalized MySQL tables

2005-04-20 Thread Leif Gregory
Hello Chris, Tuesday, April 19, 2005, 1:23:53 PM, you wrote: C Firstly, what DB are you using? MySQL. C SELECT C course.name, C location.name, C instructor.name C FROM C course C INNER JOIN location ON location.id = course.locationID C INNER JOIN instructor ON instructor.id =

Re: [PHP] Sorting table columns dynamically on normalized MySQL tables

2005-04-20 Thread Chris Boget
R Just build a JOIN query and do one query. Doing a join on four tables is ok? (serious question, not being facetious). Yes. I've built a query before (for reporting purposes) that join 15 tables... Just make sure the tables are indexed properly. thnx, Chris -- PHP General Mailing List

RE: [PHP] Sorting table columns dynamically on normalized MySQL tables

2005-04-20 Thread Jay Blanchard
[snip] Doing a join on four tables is ok? (serious question, not being facetious). [/snip] Yes, it is OK. Make sure that you have the tables properly indexed and you'll have no problems. [snip] R By definition, in SQL, if you don't specify a sort order (or in R this case a second order) then the

Re: [PHP] Sorting table columns dynamically on normalized MySQL tables

2005-04-19 Thread Chris Boget
I can do that, but is there a better way? How do you all handle dynamic sorting of normalized DBs? Firstly, what DB are you using? Secondly, just select and sort on the columns. An example query would be: SELECT course.name, location.name, instructor.name FROM course INNER JOIN

RE: [PHP] Sorting table columns dynamically on normalized MySQL tables

2005-04-19 Thread Jay Blanchard
[snip] I can do that, but is there a better way? How do you all handle dynamic sorting of normalized DBs? [/snip] Normalization has no effect on sort order where any DB is concerned. Sort order is determined in the sort clause in the query. So if you want to sort by location and you are using

Re: [PHP] Sorting table columns dynamically on normalized MySQL tables

2005-04-19 Thread Kim Briggs
Greetings, If you are still looking for tips and want to get complicated/fancy, I have seen columns used called sort_order more than a few times. This should not be too hard to maintain for things like a few buildings, etc., where the lookup table does not change much over time. You would

  1   2   3   >