Jump to content

Some table help, please.


BelowZero

Recommended Posts

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

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);
?>

 

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);
?>

 

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.