trouble getting correct info with sql
Results 1 to 3 of 3

Thread: trouble getting correct info with sql

  1. #1
    Hockey Stats Man
    Join Date
    Nov 2006
    Location
    FSJ, BC, Canada
    Posts
    293

    trouble getting correct info with sql

    I have this code below which grabs the standings for a team when i goto a team page..

    whats wrong is that its grabbing standings information from other divisions where i just want to grab the standings for the division that the team is in

    there is more code but i think the problem is within whats below

    Code:
    function Get_Stats($tid, $h_color){
        $sql_standings = " SELECT c.*, t1.name t1_name, t1.h_color t1_color, t1.a_color t1_a_color, t2.name t2_name, t2.h_color t2_color, t2.a_color t2_a_color".
               "   FROM divisions b, schedule_scores c, (select division divid from teams where id = $tid) d, teams t1, teams t2".
               "  WHERE b.id = d.divid".
               "    AND c.season = b.seasonid".
               "    AND (c.team1_div = d.divid OR c.team2_div = d.divid) AND t1.id = c.team1 AND t2.id = c.team2 ORDER BY c.date";
    mike carter

  2. #2
    To code, or not to code? jkurrle's Avatar
    Join Date
    Jul 2004
    Location
    Gainesville, VA
    Posts
    520
    It looks like you are setting the b.id equal to d.divid, but you are not setting the d.divid equal to any specific division id. Maybe if you added something like this in as well:
    PHP Code:
    // assumes '3' is a division id number
    "    AND d.divid = '3' "
    Good luck!
    99 little bugs in the code, 99 bugs in the code,
    fix one bug, compile it again...
    101 little bugs in the code....

  3. #3
    Hockey Stats Man
    Join Date
    Nov 2006
    Location
    FSJ, BC, Canada
    Posts
    293
    humm..will give that a shot and see what happens
    mike carter

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
  •