JJohnsenDK Posted January 12, 2007 Share Posted January 12, 2007 Hey Im trying to make a stat system where you can see if a player have played, scored, got a yellow card or red card. If the player have done any of these things the script should first print date, home team name, result, visitor team name, goal and card from that game and second print the number 1 in goal or card if he scored a goal or a got a card. The script working fine if the player havent done more than one action in one game, but if he for example scores two goals the script only prints the first goal from database. Same if he scores a goal and gets a card.Anyone who can help? I put in a screenshot of my database and my code:Database:[url=http://www.tallet4.monline.dk/img/db.jpg]http://www.tallet4.monline.dk/img/db.jpg[/url][code]<p><b>SAS Liga kampe:</b></p> <table class="pl_details_match_table"> <tr> <td class="pl_details_match_date">Dato</td> <td class="pl_details_match_home">Hjemme</td> <td class="pl_details_match_result">Resultat</td> <td class="pl_details_match_visitor">Ude</td> <td class="pl_details_match_mins">Min.</td> <td class="pl_details_match_goal">Mål</td> <td class="pl_details_match_card">Kort</td> <td class="pl_details_match_points">Point</td> </tr> </table><?php$sql = mysql_query("SELECT season_id, game_no, home_id, visitor_id, date FROM game") or die(mysql_error());$sql2 = mysql_query("SELECT game_id FROM actions WHERE players_ID = '".$_GET['player_id']."'");while($row2 = mysql_fetch_array($sql2)){ $game = $row2['game_id']; echo $game;$row = mysql_fetch_array($sql); if($row['game_no'] == $game){?> <table class="pl_details_match_main"> <tr> <td class="pl_details_match_date"><?=$row['date'];?></td> <td class="pl_details_match_home"><b><?=get_team_name($row['home_id']);?></b></td> <td class="pl_details_match_result"></td> <td class="pl_details_match_visitor"><b><?=get_team_name($row['visitor_id']);?></b></td> <td class="pl_details_match_mins"></td> <td class="pl_details_match_goal"> <?=get_goal($_GET['player_id'], $row['game_no'], 2006);?> </td> <td class="pl_details_match_card"> <?=get_card($_GET['player_id'], $row['game_no'], 2006);?> </td> <td class="pl_details_match_points"> </td> </tr> </table><?php }}?>[/code]Function:[code]function get_actions($player_id, $game_id, $season_id){ if(isset($player_id)){ $sql = mysql_query("SELECT goal FROM actions WHERE players_ID = '$player_id' AND game_ID = '$game_id' AND season_ID = '$season_id'") or die(mysql_error()); $row = mysql_fetch_array($sql); if($row['goal'] == 1){ $actions = $row['goal']; }else{ $actions = ""; } } return $actions;}[/code] Link to comment https://forums.phpfreaks.com/topic/33897-football-stat-system-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.