Jump to content

Jim R

Members
  • Posts

    988
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Jim R

  1. Got it...I missed that you added gamedate to the top part of the query.
  2. It doesn't appear $prevdate is keeping any values. I put... echo $prevdate . ' ' . $today; ...in the loop, and all it prints is $today each time. UPDATE: I gave it a value to start, 1980-01-01, and it just prints that date next to today's date.
  3. I didn't necessarily know how to do that... ...and I agree the fixture dates would be a good indicator. We're talking basketball here. No draws. What you tried didn't work, but I see the trigger you defined. (I've done this on a previous project, and even look at it for reference. I couldn't for the life of me get my head around. https://www.courtsideindiana.com/season-preview/19-20/sectional1920/?sectional=8 In the Carmel example (first one), the first two dates are set for 2018. The final two dates are set up for 2020.
  4. This is an aesthetic issue. As the season progresses, there will be games which have been played and upcoming games. Having added a *winner* column to the games table (a_games1920), I figured that's a good trigger to determine games played vs. upcoming games. I'd like there to be a separation between those blocks of games (past vs. future). I have tried various ways (none of which are reflected in the code below), and I can't wrap my head around how to trigger the separation just once. I'm assuming I'd be printing </table> <table> somewhere to end the first and start the second. echo '<table>'; $query_game = "SELECT team , DATE_FORMAT(gamedate, '%b %d') as date , TIME_FORMAT(gametime, '%l:%i %p') as time , home_score , away_score , winner , opponent , hora FROM ( SELECT h.schoolname as team , gamedate , gametime , home_score , away_score , winner , a.schoolname as opponent , 'h' as hora FROM a_games1920 g JOIN a_schools h ON g.home_id = h.id JOIN a_schools a ON g.away_id = a.id WHERE h.schoolname = '". $school ."' UNION ALL SELECT a.schoolname as team , gamedate , gametime , home_score , away_score , winner , h.schoolname as opponent , 'a' as hora FROM a_games1920 g JOIN a_schools a ON g.away_id = a.id JOIN a_schools h ON g.home_id = h.id WHERE a.schoolname = '".$school ."' ) x ORDER BY team, gamedate"; $result_game = mysqli_query($con,$query_game); echo mysqli_error($con); while($game = mysqli_fetch_assoc($result_game)) { // define home or away $hora = $game['hora']; if ($hora == 'h') { $hora = 'vs'; } else { $hora = '@'; } // Print the schedule echo '<div><tr><td>' . $game['date'] . '</td><td>'. $hora .' ' . $game['opponent'] . '</td>'; If (isset($game['winner'])) { if ($hora =='vs'){ echo '<td>' . $game['home_score'] . '-' . $game['away_score'] . '</td>'; } else { echo '<td>' . $game['away_score'] . '-' . $game['home_score'] . '</td>'; } } else { echo '<td>'. $game['time'] . '</td>'; } echo '</tr></div>'; } echo '</table>';
  5. I have a lot of bad ideas. ? That's what the table is named for now. I wouldn't have a table for each season. At worst, I had planned a main table and current season table, then updating the main table after each year. As I learn more, I'm seeing I won't have to do that. I'm slowly getting there.
  6. So I removed the initial gamedate and gametime instances from the query, and it all works. (I don't know why.) ? I don't know why it didn't work with the gametime lines, since I was essentially mirroring the gamedate lines, and I don't know why it works now taking gamedate and gametime out of the top part of the query altogether. $query_game = "SELECT team , DATE_FORMAT(gamedate, '%b %d') as date , TIME_FORMAT(gametime, '%l:%i %p') as time , opponent , hora FROM ( SELECT h.schoolname as team , gamedate , gametime , a.schoolname as opponent , 'h' as hora FROM a_games1920 g JOIN a_schools h ON g.home_id = h.id JOIN a_schools a ON g.away_id = a.id WHERE h.schoolname = '". $school ."' UNION ALL SELECT a.schoolname as team , gamedate , gametime , h.schoolname as opponent , 'a' as hora FROM a_games1920 g JOIN a_schools a ON g.away_id = a.id JOIN a_schools h ON g.home_id = h.id WHERE a.schoolname = '".$school ."' ) x ORDER BY team, gamedate";
  7. I want to separate the game time from the game date. Since 95% of game times are 7:30 PM, local time, I would have that as the default value in a separate column then change it when necessary. I added the column gametime, data type: TIME. Then I added gametime to the query (just below all the gamedate instances), but I'm getting 'unknown column' errors. $query_game = "SELECT team , gamedate , gametime , DATE_FORMAT(gamedate, '%b %d') as date , TIME_FORMAT(gametime, '%l:%i %p') as time , opponent , hora FROM ( SELECT h.schoolname as team , gamedate , gametime , a.schoolname as opponent , 'h' as hora FROM a_games1920 g JOIN a_schools h ON g.home_id = h.id JOIN a_schools a ON g.away_id = a.id WHERE h.schoolname = '". $school ."' UNION ALL SELECT a.schoolname as team , gamedate , gametime , h.schoolname as opponent , 'a' as hora FROM a_games1920 g JOIN a_schools a ON g.away_id = a.id JOIN a_schools h ON g.home_id = h.id WHERE a.schoolname = '".$school ."' ) x ORDER BY team, gamedate";
  8. Definitely something more to talk about. I'd have more to learn to get that done. I'm coaching basketball this weekend, so I'll be scarce. I'll DM you more about what we talked about there. I have a thought on something I'd like to share.
  9. I had forgotten to define $school inside the loop. (I had originally defined it from the URL via $_GET for testing purposes.) Now it’s: $school = $row[‘schoolname’] (from the main loop) I think it’s working now that I’ve changed it. So now I’m going expand what is printed.
  10. It's still giving me a blank result: $query_game = "SELECT team , gamedate , DATE_FORMAT(gamedate, '%d-%b-%Y') as date , opponent , hora FROM ( SELECT h.schoolname as team , gamedate , a.schoolname as opponent , 'h' as hora FROM a_games1920 g JOIN a_schools h ON g.home_id = h.id JOIN a_schools a ON g.away_id = a.id WHERE h.schoolname = '". $school ."' UNION ALL SELECT a.schoolname as team , gamedate , h.schoolname as opponent , 'a' as hora FROM a_games1920 g JOIN a_schools a ON g.away_id = a.id JOIN a_schools h ON g.home_id = h.id WHERE a.schoolname = '".$school ."' ) x ORDER BY team, gamedate";
  11. I want the Carmel games in the Carmel section, the Zionsville games in the Zionsville section. (if you looked at that link) https://www.courtsideindiana.com/season-preview/19-20/sectional1920/?sectional=8 $query_game = "SELECT team , gamedate , DATE_FORMAT(gamedate, '%d-%b-%Y') as date , opponent , hora FROM ( SELECT h.schoolname as team , gamedate , a.schoolname as opponent , 'h' as hora FROM a_games1920 g JOIN a_schools h ON g.home_id = h.id JOIN a_schools a ON g.away_id = a.id WHERE h.schoolname = '". $school ."' AND a.schoolname = '".$school ."' UNION ALL SELECT a.schoolname as team , gamedate , h.schoolname as opponent , 'a' as hora FROM a_games1920 g JOIN a_schools a ON g.away_id = a.id JOIN a_schools h ON g.home_id = h.id WHERE h.schoolname = '".$school ."' AND a.schoolname = '".$school ."' ) x ORDER BY team, gamedate"; $school is defined from another query.
  12. Game instance 1: Carmel (h) vs Zionsville Game instance 2: North Central (h) vs Carmel Game instance 3: Zionsville (h) vs North Central
  13. Somehow I think it needs to = $row['schoolname'], which comes from the query defining the Page View.
  14. I mean, it prints all three dates, even though the team is just listed in two of them. I just want the games they're playing in. (That's a fair point on the Sectional part.)
  15. Got rid of the errors (created by thinking I had a few new columns), but right now it's only printing the games of the teams involved in Sectional 8. The Sectional designation is just how the Page Views are organized. When I remove... WHERE h.sectional = 8 AND a.sectional = 8 ...it prints all the games, regardless of who is playing in them.
  16. Also, you have school name, opponent and hora (home or away) columns, as well as home_id and away_id. Redundant? Which columns do you have in the game table? I currently have (after restructuring) id, gamedate, schoolname, opponent and hora. Getting this error: Unknown column 'g.home_id' in 'on clause' Here is the link: https://www.courtsideindiana.com/season-preview/19-20/sectional1920/?sectional=8
  17. The Page takes the team from the database, but yes. It would be school ID, no? I have this schedule on the Page via an INCLUDE.
  18. I wondered if that was the table structure you'd recommend. How will that impact teams that play each other and duplication as I go back and enter scores? I should've also said the Team is determined dynamically, based on the Sectional* printed to the page. Each page will have 6-8 team listed on it. *Sectional is a post season round of our state tournament and has no direct impact on anyone's schedule. It's just how most group teams when discussing/previewing the season.
  19. I've tried a few variations of this query, and this is the closest I can get it. ? Finally getting around to printing the game schedule. Game Table: Schools Table: Query... $query_game = "SELECT * FROM a_games1920 as g join a_schools as s on s.ID = (g.homeID or g.awayID) WHERE s.sectional = '". $sectional ."' ORDER BY date"; $result_game = mysqli_query($con,$query_game); echo mysqli_error($con); while($game = mysqli_fetch_assoc($result_game)) { echo '<div>' . $game['date'] . ' | </div>'; Right now, I'm just printing the game date. I'll fill in the rest after I get this right. Each team SHOULD have two games listed, one as a home team, one as the away team. It's printing the dates of all three games. It should only be printing two dates. The plan is for each team to have their schedule listed via Date, Opponent and game time. Ultimately the output should kind of look like this... As for data entry, in theory, each row in the table would add a game instance to two teams, a home team and an away team. That would lessen the chance of duplicate entries, make it easier to check for duplicates. I'm open to a different structure.
  20. I come here to learn. A lot of times I’m not even sure which question I need to ask, but I usually work my way around to it.
  21. Simple. Thank you.
  22. I'm wanting the background of a DIV to be influenced by data from a data table. Something like this... background-color: " $color ";
  23. Thoughts on updating it automatically as each score is input? $won = $won+1 $loss = $loss+1 The model I'm basing a lot of this on updates as scores are input.
  24. Automatically figure who wins or loses based on scores input. Is that possible? Could I create a trigger for that, or would it be best to have my score input person just mark who wins and loses? Yes, I have the games table established (not specifically in its final form). League games here are just games, (more for bragging rights) but I will have a column to note those games (binary). They don't figure in tournament play in Indiana. I will definitely have a way to determine if it's a tournament game and which round (integer 0-4).
×
×
  • 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.