Jump to content

MySQL Query pulling info based on ID number


dmoase

Recommended Posts

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>

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.

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.