• 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

    • AB Download Manager 1.9.0 by Razvan Serea AB Download Manager is an open-source, feature-rich download manager designed to accelerate downloads, organize files efficiently, and provide seamless control over downloads. With support for multiple connections, resume capability, and an intuitive interface, it enhances the downloading experience for users seeking speed and reliability. The software integrates with various browsers, enabling quick link grabbing and batch downloading. It supports HTTP, HTTPS, and FTP protocols, ensuring broad compatibility with different file sources. Users can schedule downloads, set speed limits, and categorize files automatically for better organization. AB Download Manager is lightweight yet powerful, making it a great alternative to proprietary download managers. Its open-source nature allows developers to contribute, customize, and improve the software as needed. Whether you're downloading large files, managing multiple downloads at once, or seeking an ad-free experience, this tool offers a practical and efficient solution. Key features of AB Download Manager: Multi-Connection Support – Accelerates downloads by splitting files into multiple segments. Resume Capability – Allows paused or interrupted downloads to be resumed without starting over. Batch Downloading – Supports downloading multiple files at once for improved efficiency. Browser Integration – Captures download links directly from browsers for seamless operation. HTTP, HTTPS, and FTP Support – Ensures compatibility with a wide range of file sources. Download Scheduling – Enables users to automate downloads at specific times. Speed Limiting – Lets users control bandwidth usage for optimized performance. File Categorization – Automatically organizes downloaded files into designated folders. User-Friendly Interface – Simple and intuitive design for easy navigation. Cross-Platform Compatibility – Works on multiple operating systems. Ad-Free Experience – No intrusive ads or tracking for a clean user experience. AB Download Manager 1.9.0 changelog: Added Czech language support User-friendly error messages for download errors (#1252) An option to remember the last selected queue and quickly add downloads to it by long-clicking the Add button ( #1246) An option to export/import downloads using JSON format A Download button on the multi-download page for cases where users do not want to start downloads without queue processing (#1247) The app now includes a logger that can be enabled using a command-line flag (#1226) Startup errors are now logged automatically to help diagnose initialization issues Changed The default unqueued "Max Concurrent Downloads" value has been changed from "Unlimited" to 3 (This can be customized in the app settings) Improved Updated translations Added an indicator on the Android main page when resume is not supported (#1248) Extract the file name from the download link as a fallback when no response information is available (#1209) Minor UI/UX improvements Download: AB Download Manager 1.9.0 | Portable | ~80.0 MB (Open Source) Download: ARM64 | Portable ARM64 | Android Links: AB Download Manager Website | Github Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • I just started using Teams (and “New” Oiutlook) at work (instead of Slack) and both are truly abysmal pieces of software.
  • Recent Achievements

    • First Post
      DragonOfMercy earned a badge
      First Post
    • First Post
      bella52 earned a badge
      First Post
    • Reacting Well
      Techinmay earned a badge
      Reacting Well
    • Collaborator
      WndSks went up a rank
      Collaborator
    • One Month Later
      Sopa flores earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      491
    2. 2
      PsYcHoKiLLa
      205
    3. 3
      +Edouard
      153
    4. 4
      Steven P.
      84
    5. 5
      ATLien_0
      74
  • Tell a friend

    Love Neowin? Tell a friend!