473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

queries strings and time travel

52
I have a query that uses ORDER BY
I would like it to order by a string that is made after some sub queries at the end of the query.
Is there a nice trick to do this or do I need to find a way to get the string made before the query?
Aug 5 '07
51 2726
hinksta
52
OK I think i'm starting to get this but have a couple of questions.

Is it a big problem with the array starting at 0 and my first team being 1?

Can you see what's up with my third print_r?

[PHP]$teampoints=$arraypoints;
$theteampoints = (array_count_values($teampoints));

print_r($team);
echo"<br /><br />";
print_r($theteampoints);
echo"<br /><br />";

$a1=($team);
$a2=$theteampoints;
print_r(array_intersect($a1,$a2));[/PHP]

Array ( [0] => Accrington Stanley [1] => Aldershot [2] => Altrincham [3] => Aylesbury United [4] => Barnet [5] => Barrow [6] => Bath City [7] => Boston United [8] => Bromsgrove Rovers [9] => Burton Albion [10] => Cambridge United [11] => Canvey Island [12] => Carlisle United [13] => Cheltenham Town [14] => Chester City [15] => Chorley [16] => Colchester United [17] => Crawley Town [18] => Dagenham [19] => Dagenham &...

Array ( [1 wins] => 28 [63 wins] => 8 [tie] => 121 [20 wins] => 16 [28 wins] => 8 [25 wins] => 18 [36 wins] => 22 [38 wins] => 13 [47 wins] => 22 [61 wins] => 19 [11 wins] => 15 [12 wins] => 13 [32 wins] => 21 [33 wins] => 21 [72 wins] => 17 [69 wins] => 14 [3 wins] => 10 [31 wins] => 13 [57 wins] => 10 [54 wins] => 9 [10 wins] => 16 [2 wins] => 16 [18 wins] => 12 )

Array ( )
Aug 13 '07 #51
pbmods
5,821 Expert 4TB
Heya, hinksta.

The 'problem' with the third print_r() is that there is no intersection between the two tables. PHP has no way of associating the values in the first array with the values in the second array.

Since you already have the team data, you don't need the first array. And since you need to know how many 'win points' you have per team, you'll want to incorporate the team IDs into your second array as the keys.

So for example, using this data:
Team 5 vs. Team 8: Team 5 wins.
Team 3 vs. Team 12: Team 12 wins.
Team 5 vs. Team 7: Tie
Team 8 vs. Team 12: Team 8 wins.
The goal is to end up with one array that looks like this:
Expand|Select|Wrap|Line Numbers
  1. array(
  2.     5 => 4,  // One win and one tie for team 5
  3.     8 => 3,  // One win for team 8
  4.     3 => 0,  // No wins for team 3
  5.     12 => 3, // One win for team 12
  6.     7 => 1  // One tie for team 7
  7. );
  8.  
Then, using arsort(), you will end up with this:
Expand|Select|Wrap|Line Numbers
  1. array(
  2.     5 => 4,
  3.     12 => 3,
  4.     8 => 3,
  5.     7 => 1,
  6.     3 => 0
  7. );
  8.  
In this case, you now know to display team 5 first, then team 12, then team 8, and so on.
Aug 13 '07 #52

Sign in to post your reply or Sign up for a free account.

Similar topics

26
by: William Park | last post by:
How do you compare 2 strings, and determine how much they are "close" to each other? Eg. aqwerty qwertyb are similar to each other, except for first/last char. But, how do I quantify that? ...
3
by: Benny | last post by:
Hi All, In an application I write, I need to have some mapping service, where I can select two locations, which shall calculate the distance and mainly the time(could be approximate) to travel...
5
by: Martin Lacoste | last post by:
There's likely not a simple answer for this, I know, but, I thought I'd try anyways... Background.. I've been racking my brain with some queries that I thought were straightforward, but have...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
35
by: NickName | last post by:
I understand it's easy to list all saved queries of a given Access database via Msysobjects system table. However, I have not seen any posting over this NG or other similar ones that also include...
11
by: Eliot Coweye | last post by:
According to Einstein, objects of great mass affect timespace. Can a great mass of bits in a badly written C++ program affect timespace, making the harddisk were it is written on incredibly slow...
3
by: victorporton | last post by:
D.K. is traveling from City A to City B. He can stop at some designated spots only. I am trying to use Dijkstra’s algorithm to determine the “spot-to-spot” path that will get D.K. from City A to...
3
by: burtoncn | last post by:
Hi, Just a little background information on the project I am working on! I am responsible for creating a database to automatically generate travel claims for conference attendees (Approx. 300)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.