473,320 Members | 1,746 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,320 software developers and data experts.

Table join including link creation & sum

Good evening

I'm attempting to produce a single table of bets placed by players on my website. I currently have the information across two tables, as per the screenshots below:

comptipsterboard:



comptipsterselections:



Ideally, I'd like to pull the player name from comptipsterselections, and sum the selection profits for each player using group by. However, I'd like the final table to provide a link to each players selections, for which I will need the info from comptipsterboard.

My initial attempt can be found here: http://www.further-flight.co.uk/site...r/sp/2010a.php - it appears to be pulling the correct info from the comptipsterboard table, but the links aren't functioning and the profit isn't showing up correctly.

For info, here is the top scoring player's selections: http://www.further-flight.co.uk/site...2010/super.php

Expand|Select|Wrap|Line Numbers
  1.                     $query = "SELECT SUM(comptipsterselections.profit), comptipsterselections.stable
  2.                               FROM comptipsterselections INNER JOIN comptipsterboard  
  3.                               ON comptipsterselections.stable=comptipsterboard.stable
  4.                               WHERE comptipsterboard.comp = 'aintree 2010' 
  5.                               GROUP BY comptipsterselections.stable ORDER BY SUM(comptipsterselections.profit) DESC";
  6.  
  7.  
  8.                     $result = mysql_query($query) or die(mysql_error());
  9.  
  10.                 //    Set-up table
  11.  
  12.                     echo "<table class='correctenglish' border='1' cellpadding='4' cellspacing='0' width='75%'>";
  13.                     echo "<tr class='toprow'>     <th>Stable</th> <th>Daily Profit</th></tr>";
  14.  
  15.  
  16.                 // Print out result
  17.                     while($row = mysql_fetch_array($result)){
  18.  
  19.                     $link='/site/competitions/tipster'.$row['link'];
  20.  
  21.                     echo     "<tr><td>"; 
  22.                     echo     "<a href='$link'>";
  23.                     echo     $row['stable'];
  24.                     echo     "</td><td>"; 
  25.                     echo     " £". $row['SUM(comptipsterselections.profit)'];
  26.                     echo     "</td></tr>"; 
  27.                     }
  28.                     echo     "</table>";
  29.                 ?>
Any assistance would be greatly appreciated.
Apr 21 '12 #1
0 1222

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

Similar topics

2
by: drdeadpan | last post by:
Hi all, Is this legal ? SELECT a.col1,b.col2,c.col3 FROM tab1 a WITH (UPDLOCK) , tab2 b, tab3 c WHERE a.col1 = b.col1 and b.col2 = c.col1 WIll the above cause a UPDLOCK on tab1 and...
3
by: StraightEight | last post by:
Hi, I'm am looking for a little help. I need to create a SQL view which joins a few tables, and I need to return an average for a particular column where a second duplicate ID exists... Heres...
7
by: Chris | last post by:
I'm using ASP.NET and SQL Server and this might be an obviuos question for most, but if I have a table that contains several fields that I need to relate to just one field in another table, how do...
3
by: Dragon | last post by:
Can I Join two Data Table in Data set ?? Is it using the DataSet.Merge ? Any example ?
1
by: JustAQTCub | last post by:
Is it possible to obtain data from two different databased, each being on a different server. How would the query be written? example: TABLE1 on SERVER1 db1name/db1pass@instance1...
2
by: headache | last post by:
Greetings. I'm a first time poster, so feel free to clue me in to any protocol I may have inadvertently violated. I have an issue that has arisen where I need to join 3 tables where 2 of the 3...
3
by: visu | last post by:
Hi , can anyone tell me how to get the complete table schema including constraints, primary key ..etc. through sql Query in Ms access. We can get table information in MS SQL Server by means...
4
by: MPat | last post by:
Hi!! I've been trying to figure this out.. I have a form with a subform and I need to display 2 different things in this subform, that's why I came with the idea of changing the Link Child Field...
1
by: sweatha | last post by:
Dear Friends This is Sweatha. Right now I am working in the ASP.NET 2005 with VB coding & the back end is SQL SERVER 2000. My dilemma is I have to design a form with 2 DropDownListboxes. I...
14
by: issentia | last post by:
I'm working on this site: http://www.essenceofsoy.com/redesign/index2.html and I'm having a few problems with getting the layout exactly right. 1) When the menu items are rolled over, they...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.