Jump to content

[SOLVED] Go to a specific record MySql / php


kickoutbettman

Recommended Posts

Hi,

 

I'm just trying to figure out a way to go to a specific record.

It's a golf stats system.

So basically I have :

 

$totalNumberOfGame

 

I want to calculate some stats for all the games except the last one.

 

So when I calculate let's say the average of all the shots with a specific club except from the last game . (it's to calculate the previous average before the last game)

 


// There is also a 'idGame' in my holes table - I want to grab all the holes except the ones from the last game.

$club = "PW";
$query_total_shots = "SELECT * FROM holes WHERE idPlayer = '$idJPlayer' AND club = '$club' ";
$total_shots = mysql_query($query_total_shots, $golf_stats) or die(mysql_error());
$row_total_shots = mysql_fetch_array($total_shots);
$totalRows_total_shots = mysql_num_rows($total_shots);

 

So I just want to limit the numbers of row.

I want to grab all the holes except the ones from the last game

 

Hope it's clear enough.

Thank you.

Hi

 

Just avoid the last one:-

 

SELECT * FROM holes WHERE idPlayer = '$idJPlayer' AND club = '$club' AND GameDateTime != (SELECT MAX(GameDateTime) FROM holes WHERE idPlayer = '$idJPlayer' AND club = '$club' )

 

This way you can use SQL numeric functions to work out the average.

 

Or if you want to do it in php, this will bring all the rows back except the last one (issue being that I presume there are multiple holes per game):-

 

SELECT * FROM holes WHERE idPlayer = '$idJPlayer' AND club = '$club' ORDER BY GameDateTime DESC LIMIT 1,18446744073709551615

 

All the best

 

Keith

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.