BelowZero Posted March 10, 2011 Share Posted March 10, 2011 The following code produces this page: http://www.beat-the-spread.net/week1.php <?php $result = mysql_query(" SELECT * FROM schedule JOIN teams ON schedule.team = teams.team_id WHERE week_id ='1'"); echo "<table width=643 border=1>\n"; echo "<th>Date</th><th>Team</th><th>Owner</th><th>Spread</th><th>Score</th><th>Bet</th><th>Cover</th><th>Points</th>"; while($row = mysql_fetch_array( $result )) { $i=1; if ($row['game_id']='$i') { echo "<tr><td>"; echo $row['date']; echo "</td><td>"; echo $row['team_name']; echo "</td><td>"; echo $row['owner']; echo "</td><td>"; echo $row['pt_spread']; echo "</td><td>"; echo $row['team_pts']; echo "</td><td>"; echo $row['team_bet']; echo "</td><td>"; echo $row['team_cover']; echo "</td><td>"; echo $row['owner_pts']; echo "</td></tr>"; } $i++; } echo "</table>"; mysql_close($con); ?> What I'd like is a space between each game, so that it's easier to view the results. So I'd have 2 rows, then a space of some sort, then 2 more rows, etc. Can anyone help me accomplish this? Thanks. Link to comment https://forums.phpfreaks.com/topic/230163-some-table-help-please/ Share on other sites More sharing options...
MadLittleMods Posted March 10, 2011 Share Posted March 10, 2011 Try this... <?php $result = mysql_query(" SELECT * FROM schedule JOIN teams ON schedule.team = teams.team_id WHERE week_id ='1'"); echo "<table width=643 border=1>\n"; echo "<th>Date</th><th>Team</th><th>Owner</th><th>Spread</th><th>Score</th><th>Bet</th><th>Cover</th><th>Points</th>"; $table_row_count = 0; while($row = mysql_fetch_array( $result )) { $i=1; if ($row['game_id']='$i') { echo "<tr><td>"; echo $row['date']; echo "</td><td>"; echo $row['team_name']; echo "</td><td>"; echo $row['owner']; echo "</td><td>"; echo $row['pt_spread']; echo "</td><td>"; echo $row['team_pts']; echo "</td><td>"; echo $row['team_bet']; echo "</td><td>"; echo $row['team_cover']; echo "</td><td>"; echo $row['owner_pts']; if ($table_row_count % 2 && $table_row_count != 0) { echo "</td><td>"; echo ' <br><br> '; } echo "</td></tr>"; $table_row_count++; } $i++; } echo "</table>"; mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/230163-some-table-help-please/#findComment-1185300 Share on other sites More sharing options...
BelowZero Posted March 10, 2011 Author Share Posted March 10, 2011 It now looks like this. http://www.beat-the-spread.net/week1.php Right idea, but not what I was looking for. Can I create a table per game? Link to comment https://forums.phpfreaks.com/topic/230163-some-table-help-please/#findComment-1185312 Share on other sites More sharing options...
MadLittleMods Posted March 10, 2011 Share Posted March 10, 2011 woops.. do this <?php $result = mysql_query(" SELECT * FROM schedule JOIN teams ON schedule.team = teams.team_id WHERE week_id ='1'"); echo "<table width=643 border=1>\n"; echo "<th>Date</th><th>Team</th><th>Owner</th><th>Spread</th><th>Score</th><th>Bet</th><th>Cover</th><th>Points</th>"; $table_row_count = 0; while($row = mysql_fetch_array( $result )) { $i=1; if ($row['game_id']='$i') { echo "<tr><td>"; echo $row['date']; echo "</td><td>"; echo $row['team_name']; echo "</td><td>"; echo $row['owner']; echo "</td><td>"; echo $row['pt_spread']; echo "</td><td>"; echo $row['team_pts']; echo "</td><td>"; echo $row['team_bet']; echo "</td><td>"; echo $row['team_cover']; echo "</td><td>"; echo $row['owner_pts']; echo "</td></tr>"; if ($table_row_count % 2 && $table_row_count != 0) { echo ' <tr style="height: 10px"></tr> '; } $table_row_count++; } $i++; } echo "</table>"; mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/230163-some-table-help-please/#findComment-1185317 Share on other sites More sharing options...
BelowZero Posted March 10, 2011 Author Share Posted March 10, 2011 Thanks! Looks much better now. Link to comment https://forums.phpfreaks.com/topic/230163-some-table-help-please/#findComment-1185338 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.