Jump to content

Barand

Moderators
  • Posts

    24,338
  • Joined

  • Last visited

  • Days Won

    795

Everything posted by Barand

  1. Why? If you know who's playing and the scores then you know the winner. (BTW, what if there is a draw?). Don't store derived data. The fixture date is good indicator of those played and those not yet played. try this 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 , gamedate -- required for date comparisons 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); $prevdate = ''; $today = date('Y-m-d'); while($game = mysqli_fetch_assoc($result_game)) { // define home or away $hora = $game['hora']; if ($hora == 'h') { $hora = 'vs'; } else { $hora = '@'; } // Print the schedule if ($prevdate <= $today && $game['gamedate'] > $today) { // HAVE WE CHANGED TO FUTURE FIXTURES? echo "<tr><td colspan='3' style='background-color:black; color:white'>Future fixtures...</td></tr>\n"; $prevdate = $game['gamedate'] ; } 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>';
  2. ... which probably won't work if you are getting a blank page. You will need to catch any startup errors so the settings need to be in your php.ini file.
  3. It's objecting to the number of parameters. Your query needs 3 you only provided 2. (You cannot re-use :f (you'll need :e, :f, :g) $sql = $this->Db->prepare("UPDATE ** SET data = CASE WHEN data IS NULL THEN :f ELSE (CONCAT(data,:g)) END WHERE lead=:e"); $sql->execute(array( ':e' => $data["lead"], ':f' => $data["comment"] . $data["text"], ':g' => $data["comment"] . $data["text"] ));
  4. Try it without the <?php echo ... ?> You are already inside a php block of code echo "<article data-style='$label_style' style='background-image:url({$event->data->thumbnails['medium']})' class='mec-event-article mec-clear {$this->get_event_classes($event)} $colorful_bg_color>";
  5. First thing to do is correct your case statement CASE WHEN data IS NULL THEN :f ELSE (CONCAT(data,:f)) END Check content of $data array.
  6. Query looks OK. I see the game table is named "a_games1920". How many game tables do have and do they all have a gametime column? Having a game table for each season is another of your bad ideas. You mentioned earlier about getting a coach's record over, say, the last 10 years. You will now have to query 10 different game tables to acclomplish that. All the games have a date so you know which seaon they belong to without adding another problem.
  7. Use the forums code boxes (<> button on the toolbar) and stop posting black text on a black background.
  8. One thing you shouldn't do is run an outer query then loop through the results running further queries. It is inefficient and heavy on resources. You should use JOINS to get all the data you need in a single query
  9. I am surprised you are getiing any results at all. Those where clauses should give only those matches where the home team and away team are the same team ($school) The first SELECT clause (home matches) should have "WHERE h.schoolname = '$school' " and the second should have "WHERE a.schoolname = '$school' " (Or use school_id , preferably)
  10. I take it you just want the Carmel games, yes? What is you current query?
  11. What 3 dates? You have home games and away games so what is the third - do you also have meet-in-the-middle games?
  12. Is that a good thing or a bad thing? (I put in the "WHERE sectional = " bits in because you had it in your query. "8" just happened to be the value I had put in that column in my data.)
  13. My game table is CREATE TABLE `game` ( `game_id` int(11) NOT NULL AUTO_INCREMENT, `gamedate` date DEFAULT NULL, `home_id` int(11) DEFAULT NULL, `away_id` int(11) DEFAULT NULL, `home_score` int(11) DEFAULT NULL, `away_score` int(11) DEFAULT NULL, `tournament_id` int(11) DEFAULT NULL, `round` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`game_id`), KEY `fk_game_school1_idx` (`home_id`), KEY `fk_game_school2_idx` (`away_id`), KEY `fk_game_tourn_idx` (`tournament_id`), KEY `idx_game_gamedate` (`gamedate`), CONSTRAINT `fk_game_school1` FOREIGN KEY (`home_id`) REFERENCES `school` (`school_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_game_school2` FOREIGN KEY (`away_id`) REFERENCES `school` (`school_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_game_tourn` FOREIGN KEY (`tournament_id`) REFERENCES `tournament` (`tournament_id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=241 DEFAULT CHARSET=utf8;
  14. Do you mean you want to add a "WHERE team = '$teamname' "
  15. echo "<td> <input type='text' name='reply[]'class="ansbox" value='$value'></td>"; Have you tried this?
  16. It is likely that you are looking for something like this 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 game g JOIN school h ON g.home_id = h.school_id JOIN school a ON g.away_id = a.school_id WHERE h.sectional = 8 AND a.sectional = 8 UNION ALL SELECT a.schoolname as team , gamedate , h.schoolname as opponent , 'A' as hora FROM game g JOIN school a ON g.away_id = a.school_id JOIN school h ON g.home_id = h.school_id WHERE h.sectional = 8 AND a.sectional = 8 ) x ORDER BY team, gamedate; +-----------+------------+-------------+-----------+------+ | team | gamedate | date | opponent | hora | +-----------+------------+-------------+-----------+------+ | School 1 | 2018-11-10 | 10-Nov-2018 | School 13 | H | | School 1 | 2018-11-17 | 17-Nov-2018 | School 5 | A | | School 1 | 2018-11-24 | 24-Nov-2018 | School 2 | H | | School 1 | 2018-12-01 | 01-Dec-2018 | School 7 | H | | School 1 | 2018-12-15 | 15-Dec-2018 | School 9 | A | | School 1 | 2018-12-22 | 22-Dec-2018 | School 8 | H | | School 1 | 2019-01-19 | 19-Jan-2019 | School 11 | A | | School 1 | 2019-01-26 | 26-Jan-2019 | School 4 | H | | School 1 | 2019-02-02 | 02-Feb-2019 | School 8 | A | | School 1 | 2019-02-23 | 23-Feb-2019 | School 6 | H | | School 1 | 2019-03-09 | 09-Mar-2019 | School 12 | H | | School 1 | 2019-03-30 | 30-Mar-2019 | School 9 | H | | School 1 | 2019-04-06 | 06-Apr-2019 | School 6 | A | | School 1 | 2019-04-13 | 13-Apr-2019 | School 10 | A | | School 1 | 2019-04-20 | 20-Apr-2019 | School 13 | A | | School 1 | 2019-04-27 | 27-Apr-2019 | School 7 | A | | School 1 | 2019-05-04 | 04-May-2019 | School 11 | H | | School 1 | 2019-05-18 | 18-May-2019 | School 12 | A | | School 1 | 2019-05-25 | 25-May-2019 | School 10 | H | | School 1 | 2019-06-01 | 01-Jun-2019 | School 4 | A | | School 1 | 2019-06-08 | 08-Jun-2019 | School 2 | A | | School 1 | 2019-06-15 | 15-Jun-2019 | School 5 | H |
  17. Don't. Just enter and store the scores. Databases should not store derived data. Get the total wins and losses when you need them with a query.
  18. Using my data model you can get results like +---------+--------+------+-------+------+-------+--------+ | School | Played | Won | Drawn | Lost | PDiff | Points | +---------+--------+------+-------+------+-------+--------+ Points awarded | Cowdrey | 6 | 4 | 2 | 0 | 8 | 14 | Win = 3 | Laker | 6 | 3 | 2 | 1 | 6 | 11 | Draw = 1 | Jardine | 6 | 1 | 2 | 3 | -6 | 5 | Lose = 0 | Grace | 6 | 0 | 2 | 4 | -8 | 2 | +---------+--------+------+-------+------+-------+--------+ This can be for schools or coaches, either for the current season or going back as far as your data allows.
  19. Use a hidden field <?php $rs = [[1,2,3],[2,3,4],[3,4,5]]; $jrs = json_encode($rs); echo "<input id='rs' type='hidden' value='$jrs'>"; ?> then <script type="text/javascript"> $().ready( function() { var rs = JSON.parse( $("#rs").val() ) alert( rs[2][0] ) // 3 }) </script>
  20. The query needs to know exactly which table each column comes from. It's the output from that query to PHP that doesn't.
  21. Check what is in $_POST['pcolors'] if(isset($_POST['pColors'])) { var_dump($_POST['pColors']); }
×
×
  • 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.