• 0

Help with php


Question

I have the following script written to display players appearances by every 50, so their first game appears first, then their 50th, etc, see the image below..


public function get_player_milestones( stdClass $player )
{
$query = $this->dbo->prepare(
'SELECT
returnTable.*
FROM ( SELECT @rownum := @rownum + 1 AS milestone_count, seasonstats.*
FROM seasonstats
WHERE id = ANY
(
SELECT matchid
FROM seasonteamstats AS playergames, (SELECT @rownum:=0) variableInit
WHERE firstname = :firstname
AND
lastname = :lastname
)
ORDER BY date
)
AS
returnTable
WHERE returnTable.milestone_count = 1
OR
( returnTable.milestone_count )
MOD 50 = 0;
');

$query->bindParam(':firstname', $player->firstname, PDO::PARAM_STR );
$query->bindParam(':lastname', $player->lastname, PDO::PARAM_STR );
$query->execute();

return $query->fetchAll(PDO::FETCH_OBJ);
}
[/CODE]

What I want to do now is display the games the player scored in. I have almost got it by adding

[CODE]
AND goals+penalties > 0
[/CODE]

under lastname = :lastname. Problem is, its not taking into account when a player has scored 2, or more in a game. So basically, if a players scored 51 goals, the 50 is missing if they've scored more than 2 in one game. Hopefully someone understood all that :D

post-103369-0-07936900-1334060236_thumb.

Link to comment
https://www.neowin.net/forum/topic/1069362-help-with-php/
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I take it you're storing goals per game, not individual goals? It might be easier to create a table that just lists a player ID, game #, and an entry every time a goal is scored (and maybe a type, if you want to separate out standard goals from penalties). Then you could join that with the players table by ID, and limit to whatever you want (1,50,100, etc).

You could also return an array of all the games a player has scored in and run a loop that grabs the game name at 1 and 50.

Link to comment
https://www.neowin.net/forum/topic/1069362-help-with-php/#findComment-594790214
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Absolutely 👍
    • Exactly what I was thinking. All of a sudden in span of a month multiple CEO's from scam altman to this clown has had sudden change of heart does not seem organic change lol
    • Microsoft releases Visual Studio Code 1.124 with smarter autonomous AI agents by Paul Hill Microsoft has just released Visual Studio Code 1.124 with a focus on faster agent workflows and improved agent autonomy. Microsoft outlined the following features as the key items in this update: Autopilot: Autopilot, enabled by default, is now smarter to determine when a task is truly done. Background sessions: Quickly send a request in the background and keep composing the next session. Session navigation: Search, jump, and step through agent sessions with the keyboard. Browser history: Revisit and search pages you've already opened in the integrated browser. With VS Code 1.124, Microsoft has enabled Autopilot by default. For those that don’t know, Autopilot is a chat permission level that you can pick to give agents permission to take initiative and act autonomously, without needing explicit user approval for each action. Also related to Autopilot, Microsoft introduced Advanced Autopilot, which changes how Autopilot decides when to keep iterating and when to finish. This helps you get more complete results without manually monitoring loops. This feature works using a small utility model that reads a transcript of the chat and decides when the task is done. Another new feature in 1.124 is the Agents window, which lets you easily explore, iterate on, and review agent sessions across projects and machines. Previously, starting a new agent session meant waiting for it to load before you could compose the next one. With this update, sessions can be requested in the background. This VS Code update also brings session navigation updates to switch between them more quickly. The update also lets you reload or reopen the Agents window so that it no longer loses your layout, so you will land back where you left off. If you use the integrated browser in VS Code, you will notice that it now retains the history of visited pages. Suggestions will now show when typing in the URL bar and can be managed by using Ctrl+H within a browser tab. The browser now also lets you customize the toolbar more; just right-click on the toolbar area to the right of the URL input. Finally, the browser has faster agentic text entry. Another improvement is experimental enterprise-managed Copilot plugin policies that allow admins to centrally control which chat plugins and plugin marketplaces are available to developers. If you have VS Code installed, 1.124 should install automatically, or you'll get a prompt. If you don't have it installed, get it here.
  • Recent Achievements

    • First Post
      X-No-file earned a badge
      First Post
    • One Month Later
      johnjacobb40 earned a badge
      One Month Later
    • One Year In
      Primer1st earned a badge
      One Year In
    • Experienced
      JayZJay went up a rank
      Experienced
    • Reacting Well
      Sir_Timbit earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      513
    2. 2
      PsYcHoKiLLa
      217
    3. 3
      +Edouard
      145
    4. 4
      ATLien_0
      86
    5. 5
      Steven P.
      86
  • Tell a friend

    Love Neowin? Tell a friend!