Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


Results 1 to 4 of 4

Thread: Plugin Problem

  1. #1

    Plugin Problem

    First time post, and of course it is a help question.

    I am using a WP plug-in to display previous and next games in a season. (Leaguemanager is the plug-in name - Link http://wordpress.org/extend/plugins/leaguemanager/ ). The challenge I am having is that the previous game only displays the first game of the season, not the actual previous game...

    The following code is pulled from the shortcode.php file in the lib folder of the plugin.

    Here is the code for the next game which works...

    $next_matches = $leaguemanager->getMatches("( `home_team` = {$team->id} OR
    `away_team` = {$team->id} ) AND DATEDIFF(NOW(), `date`) <= 0");
    $next_match = $next_matches[0];
    Here is the code for the previous game that pulls the first game of the
    season, not the actual previous game.

    $prev_matches = $leaguemanager->getMatches("( `home_team` = {$team->id} OR
    `away_team` = {$team->id} ) AND DATEDIFF(NOW(), `date`) > 0");
    $prev_match = $prev_matches[0];
    It's probably something really simple, but I have been hacking away at this for about 8 hours and I cannot get it to work. On a side note if you swap the "0" for a "1" in this line $prev_match = $prev_matches[0]; it will show the second game of the season.

    Thanks for any help!

  2. #2
    PHP Code:
    $prev_matches $leaguemanager->getMatches("( `home_team` = {$team->id} OR
    `away_team` = 
    {$team->id} ) AND DATEDIFF(NOW(), `date`) > 0  ORDER BY `date` DESC");
    $prev_match $prev_matches[0]; 
    Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
    Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.

  3. #3
    Thanks for the input, I tried that and here is the PHP error I received:

    [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY `date` ASC' at line 1]
    SELECT `group`, `home_team`, `away_team`, DATE_FORMAT(`date`, '%Y-%m-%d %H:%i') AS date, DATE_FORMAT(`date`, '%e') AS day, DATE_FORMAT(`date`, '%c') AS month, DATE_FORMAT(`date`, '%Y') AS year, DATE_FORMAT(`date`, '%H') AS `hour`, DATE_FORMAT(`date`, '%i') AS `minutes`, `match_day`, `location`, `league_id`, `home_points`, `away_points`, `winner_id`, `loser_id`, `post_id`, `season`, `id`, `custom` FROM wp_leaguemanager_matches WHERE ( `home_team` = 1 OR `away_team` = 1 ) AND DATEDIFF(NOW(), `date`) > 0 ORDER BY `date` DESC ORDER BY `date` ASC

  4. #4
    I got some more advice and this seems to do the trick..
    $prev_match = end($prev_matches);

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About kirupa.com Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012