dmoase Posted March 22, 2008 Share Posted March 22, 2008 Hey Everyone, I am going to have a hockey pool and need to create team pages for each entrant. I would like to display the info in a table. I have it working now but I believe that it's going to be too stressful on the server since each team will have about 30 players. Is there any better way to do this? Any help is very much appreciated. Here is a sample of the code for two players <?php $sql = "SELECT * FROM Players where ID = '5' "; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $Pos = $row['Position']; $Name = $row['Name']; $Team = $row['Team']; $Goals = $row['Goals']; $Assists = $row['Assists']; $Hat_Trick = $row['Hat_Trick']; $Plus_Minus = $row['Plus_Minus']; $Shots_Blocked = $row['Shots_Blocked']; $Total = $row['Total_Points']; } ?> <tr bgcolor="#d5d5d5"> <td width ="7%" align="center"><? echo $Pos; ?></td> <td width ="28%"><? echo $Name; ?></td> <td width ="23%"><? echo $Team; ?></td> <td width ="7%" align="center"><? echo $Goals; ?></td> <td width ="7%" align="center"><? echo $Assists; ?></td> <td width ="7%" align="center"><? echo $Hat_Trick; ?></td> <td width ="7%" align="center"><? echo $Plus_Minus; ?></td> <td width ="7%" align="center"><? echo $Shots_Blocked; ?></td> <td width ="7%" align="center"><? echo $Total; ?></td> </tr> <?php $sql = "SELECT * FROM Players where ID = '15' "; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $Pos2 = $row['Position']; $Name2 = $row['Name']; $Team2 = $row['Team']; $Goals2 = $row['Goals']; $Assists2 = $row['Assists']; $Hat_Trick2 = $row['Hat_Trick']; $Plus_Minus2 = $row['Plus_Minus']; $Shots_Blocked2 = $row['Shots_Blocked']; $Total2 = $row['Total_Points']; } ?> <tr bgcolor="#98bad3"> <td width ="7%" align="center"><? echo $Pos2; ?></td> <td width ="28%"><? echo $Name2; ?></td> <td width ="23%"><? echo $Team2; ?></td> <td width ="7%" align="center"><? echo $Goals2; ?></td> <td width ="7%" align="center"><? echo $Assists2; ?></td> <td width ="7%" align="center"><? echo $Hat_Trick2; ?></td> <td width ="7%" align="center"><? echo $Plus_Minus2; ?></td> <td width ="7%" align="center"><? echo $Shots_Blocked2; ?></td> <td width ="7%" align="center"><? echo $Total2; ?></td> </tr> Link to comment https://forums.phpfreaks.com/topic/97325-mysql-query-pulling-info-based-on-id-number/ Share on other sites More sharing options...
ryeman98 Posted March 22, 2008 Share Posted March 22, 2008 So you're trying to display all of the players for a certain team, or? If so, then what tables do you have and how are they connected? Link to comment https://forums.phpfreaks.com/topic/97325-mysql-query-pulling-info-based-on-id-number/#findComment-498068 Share on other sites More sharing options...
dmoase Posted March 22, 2008 Author Share Posted March 22, 2008 well how it works is everyone that participates picks a team of roughly 30 players from groups I have made. I have a database with all of these players on in one table. What I'm looking to do is enter the points info straight into the database so the info will then automatically update each entrant's team page.. I have created Fields "ID" as the Primary Key, and the other fields are "Name", "Team", "Goals", "Assists", "Hat_Trick", "Plus_Minus", "Shots_Blocked", and "Total_Points". Thank you for the response ryeman98 and if you need any more info please ask. Link to comment https://forums.phpfreaks.com/topic/97325-mysql-query-pulling-info-based-on-id-number/#findComment-498078 Share on other sites More sharing options...
ryeman98 Posted March 22, 2008 Share Posted March 22, 2008 Oh so you don't actually have users or what? If you do, there should be another field named like user_id so you can see who owns the player and then print them out that way SELECT * FROM `Players` WHERE user_id='#' Link to comment https://forums.phpfreaks.com/topic/97325-mysql-query-pulling-info-based-on-id-number/#findComment-498083 Share on other sites More sharing options...
dmoase Posted March 22, 2008 Author Share Posted March 22, 2008 Nope no username's the ID I have is just for the player so I know which one I'm pulling from the database. Maybe next year I can make it easier on myself and add that but for now I'm not all that familiar with PHP and am just trying to get it all going doing it manually. Also people are able to have the same player as well. Link to comment https://forums.phpfreaks.com/topic/97325-mysql-query-pulling-info-based-on-id-number/#findComment-498279 Share on other sites More sharing options...
ryeman98 Posted March 22, 2008 Share Posted March 22, 2008 I'm still not totally sure about what you mean. Do you think you could provide an example on what you're trying to do? Link to comment https://forums.phpfreaks.com/topic/97325-mysql-query-pulling-info-based-on-id-number/#findComment-498369 Share on other sites More sharing options...
dmoase Posted March 22, 2008 Author Share Posted March 22, 2008 Sorry about not being clear enough. Here is my entire plan, I'm going to make up about 30 groups with around 10 players in each group, every person that wants to enter will choose one player from each these groups and send me their picks. I then make a page for their team to display the statistics which I have all the info in the fields of the database and that's where I will be making the changes to the stats, so they and everyone else in the pool can go to that persons page to see all of their players and the how many points they have. In the database I made the field "ID" as an auto increment starting from 1 so I would know the proper player to pull to make sure the stats are correct. Here is a link to a Test Team page http://daftnews.com/hockey/team_test.php I am going to add more players as well, so far I've just been working on the making sure the info is correct for now. Link to comment https://forums.phpfreaks.com/topic/97325-mysql-query-pulling-info-based-on-id-number/#findComment-498385 Share on other sites More sharing options...
ryeman98 Posted March 23, 2008 Share Posted March 23, 2008 Now I understand. Alright well since it's not user interactive, you'll have to do them manually, especially since people can choose the same players. Wish you luck bud, and Go Oilers! Link to comment https://forums.phpfreaks.com/topic/97325-mysql-query-pulling-info-based-on-id-number/#findComment-498666 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.