Forum Moderators: coopster
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="13%"><div align="left"><img src="images/team logos/servo.jpg" width="90" height="100" /></div></td>
<td width="87%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="left"><span class="style7">Servo (Servo222)</span></div></td>
</tr>
<tr>
<td><div align="left"><span class="style7">Eustis Assassins</span></div></td>
</tr>
<tr>
<td><div align="left"><span class="style7">Division</span></div></td>
</tr>
<tr>
<td><div align="left"><span class="style7">Experiece: 1st Season</span></div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td><br />
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td bgcolor="6B2705"><div align="center"><span class="style7">Year</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Record</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">At Home</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Away</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Div Record</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Pass Yds</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Pass Tds</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Rush Yds</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Rush Tds</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Off PPG</a></span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Def PAPG</a></span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">INTs</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Def Tds</span></div></td>
</tr>
<tr>
<td><div align="center"><span class="style7">2008</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
<td><div align="center"><span class="style7">0</span></div></td>
</tr>
</table></td></tr>
</table> [edited by: Servo at 3:39 pm (utc) on Sep. 4, 2008]
[edited by: eelixduppy at 4:48 pm (utc) on Sep. 4, 2008]
[edit reason] removed URL [/edit]
$output = '';
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$output .= '
<tr bgcolor="FFCCFF">
<td align="center"><span class="style7">' . $row[year1] . '</span></td>
<td align="center"><span class="style7">' . $row[record] . '</span></td>
<td align="center"><span class="style7">' . $row[at_home] . '</span></td>
<td align="center"><span class="style7">' . $row[away] . '</span></td>
<td align="center"><span class="style7">' . $row[div_record] . '</span></td>
<td align="center"><span class="style7">' . $row[pass_yds] . '</span></td>
<td align="center"><span class="style7">' . $row[pass_tds] . '</span></td>
<td align="center"><span class="style7">' . $row[rush_yds] . '</span></td>
<td align="center"><span class="style7">' . $row[rush_tds] . '</span></td>
<td align="center"><span class="style7">' . $row[off_ppg] . '</span></td>
<td align="center"><span class="style7">' . $row[def_papg] . '</span></td>
<td align="center"><span class="style7">' . $row[ints] . '</span></td>
<td align="center"><span class="style7">' . $row[def_tds] . '</span></td>
</tr>';}
echo $output;
Is this what you are looking for? It would build all of the rows/columns and then output them when complete.
[edited by: shdwmage at 7:50 pm (utc) on Sep. 4, 2008]
I would add an additional field on your table to flag which ones you are looking to print otherwise, I would just do a where value = "result" or value2 = "result2"
or where new_field = 'yes'
I guess it helps to re-read a bit more before responding!
if you are suggesting that i add a ID field to tag it that fine..but then how do i get it so i only pull certain fields from that row in the table...sorry if this is confusing (i think i am confusing myself..lol)
edit: the whole point of this is i am making a statistics website with a bunch of users (up to 32) and on the user page i want to list all the users with all there stats in that table format for each user. (if that makes it anymore clearer)
[edited by: Servo at 10:24 pm (utc) on Sep. 4, 2008]
$query = "SELECT * FROM table WHERE..." // You need to complete this
$result = mysql_query($query);
Have a look at SELECT & WHERE at [w3schools.com...] to get you going.
Below are a couple examples
This example will select every thing that is in table_a where the uid (the user id of the person thats logged in) is equal to 1
SELECT * FROM table_a WHERE uid = 1
The following example is probably a poor coding practice, but you can have a field in your table that corraletes to the user ids that are capable of viewing the file.
SELECT * FROM table_b WHERE access_ids like '%,$uid,%'
In this example the $uid is equal to the user id of the current logged in user. Using the like as well as the % signs will allow you to search just a part of the value thats stored in the database.
So depending on how you want to structure your id field, there are a couple of examples of how you can access the data.
If you would like some more clarification, I will try.
Select year1,record,at_home,away,div_record,... FROM table_a
To just pull the data out of those fields into the array.
Please note the ... is just a continuation of all the fields you want to pull seperated by a comma.
<?php
$hostname_LL = "localhost";
$database_LL = "database";
$username_LL = "user";
$password_LL = "pass";
$LL = mysql_pconnect($hostname_LL, $username_LL, $password_LL) or trigger_error(mysql_error(),E_USER_ERROR);mysql_select_db($database_LL, $LL);
$query = ("SELECT 'Record', 'At_Home', 'Away', 'Division_Record', 'Pass_Yds', 'Pass_TDs', 'Rush_Yds', 'Rush_TDs', 'Off_PPG', 'Def_PAPG', 'INT', 'Def_TDs' FROM statistics WHERE ID='19'");
$result = mysql_query($query);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="13%"><div align="left"><img src="images/team logos/servo.jpg" width="90" height="100" /></div></td>
<td width="87%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="left"><span class="style7">Servo (Servo222)</span></div></td>
</tr>
<tr>
<td><div align="left"><span class="style7">Eustis Assassins</span></div></td>
</tr>
<tr>
<td><div align="left"><span class="style7">Division</span></div></td>
</tr>
<tr>
<td><div align="left"><span class="style7">Experiece: 1st Season</span></div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td><br />
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td bgcolor="6B2705"><div align="center"><span class="style7">Year</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Record</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">At Home</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Away</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Div Record</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Pass Yds</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Pass Tds</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Rush Yds</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Rush Tds</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Off PPG</a></span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Def PAPG</a></span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">INTs</span></div></td>
<td bgcolor="6B2705"><div align="center"><span class="style7">Def Tds</span></div></td>
</tr>
<tr>
<td><div align="center"><span class="style7">2008</span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['Record']; ?></span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['At_Home']; ?></span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['Away']; ?></span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['Division_Record']; ?></span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['Pass_Yds']; ?></span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['Pass_Tds']; ?></span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['Rush_Yds']; ?></span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['Rush_TDs']; ?></span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['Off_PPG']; ?></span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['Def_PAPG']; ?></span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['INT']; ?></span></div></td>
<td><div align="center"><span class="style7"><?php echo $result['Def_TDs']; ?></span></div></td>
</tr>
</table></td></tr>
</table>
[edited by: Servo at 1:47 pm (utc) on Sep. 6, 2008]
Try:
SELECT Record , At_Home , Away , Division_Record , Pass_Yds , Pass_TDs , Rush_Yds , Rush_TDs , Off_PPG , Def_PAPG , INT , Def_TDs FROM statistics WHERE ID='19'
list each field without the '' and see if it works.
Your code will also only print one line.
<?php
$output = '';
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$output .= '
<tr bgcolor="FFCCFF">
<td align="center"><span class="style7">' . $row[year1] . '</span></td>
<td align="center"><span class="style7">' . $row[record] . '</span></td>
<td align="center"><span class="style7">' . $row[at_home] . '</span></td>
<td align="center"><span class="style7">' . $row[away] . '</span></td>
<td align="center"><span class="style7">' . $row[div_record] . '</span></td>
<td align="center"><span class="style7">' . $row[pass_yds] . '</span></td>
<td align="center"><span class="style7">' . $row[pass_tds] . '</span></td>
<td align="center"><span class="style7">' . $row[rush_yds] . '</span></td>
<td align="center"><span class="style7">' . $row[rush_tds] . '</span></td>
<td align="center"><span class="style7">' . $row[off_ppg] . '</span></td>
<td align="center"><span class="style7">' . $row[def_papg] . '</span></td>
<td align="center"><span class="style7">' . $row[ints] . '</span></td>
<td align="center"><span class="style7">' . $row[def_tds] . '</span></td>
</tr>';}
echo $output;
?>
This will make it show multiple rows. Plus make it a bit easier on the server as far as resources because it will make the whole table with php, and then print it.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INT , Def_TDs FROM statistics WHERE ID='19'' at line 1