0

I am trying to figure out how to link items in a row of a table while keeping the row in place, I have the following code:

echo "<br><br><table border=0 cellpadding=3>";
echo "<td><b>Player Name</b></td>";
echo "<td><b>Position</b></td>";
echo "<td><b>Height</b></td>";
echo "<td><b>Weight</b></td>";
echo "<td><b>Birthdate</b></td>"; 
echo "<td><b>NHL Rights</b></td>";
echo "<td><b>CNGHL Team</b></td>";
echo "<td><b>Current Team</b></td>";
echo "<td><b>Current League</b></td>";

while($row = mysql_fetch_array($oteaminfo)) 
{
echo "<tr>";
echo "<td>".$row['FullName']."</td> ";
echo "<td>".$row['Position']."</td> ";
echo "<td>".$row['Height']."</td> ";
echo "<td>".$row['Weight']."</td> ";
echo "<td>".$row['DOB']."</td> ";
echo "<td>".$row['Team']."</td> ";
echo "<td>".$row['CNGHLRights']."</td> ";
echo "<td>".$row['InternationalTeam']."</td> ";
echo "<td>".$row['InternationLeague']."</td> ";
echo "</tr>";
}
echo "</table>";

I have tried using

     echo "<a href=\"cnghlplayers.php?  PlayerID=".$row['PlayerID']."\">".$row['FullName']."<br>";

In Place of the

      echo "<td>".$row['FullName']."</td> ";

In the table but It puts the links into a new row above my current table. Any help would be greatly appreciated, I tried searching for this topic but I couldn't find any information that was helpful.

Thanks!

4

3 回答 3

1

只需将<td>元素包裹起来:

echo '<td><a href="cnghlplayers.php?PlayerID='.$row['PlayerID'].'">'.$row['FullName'].'</a></td>';
于 2013-09-01T20:54:59.620 回答
1

Wrap your link with TD:

echo "<td><a href=\"cnghlplayers.php?  PlayerID=".$row['PlayerID']."\">".$row['FullName']."</a></td>";
于 2013-09-01T20:56:12.687 回答
1

对此进行测试,您的表格标记存在一些问题。这也应该更容易阅读。

?> <!-- this line ends your php code so that you can format the HTML sanely -->
<br />
<br />
<table border=0 cellpadding=3>
        <tr>
            <td><b>Player Name</b></td>
            <td><b>Position</b></td>
            <td><b>Height</b></td>
            <td><b>Weight</b></td>
            <td><b>Birthdate</b></td> 
            <td><b>NHL Rights</b></td>
            <td><b>CNGHL Team</b></td>
            <td><b>Current Team</b></td>
            <td><b>Current League</b></td>
        </tr>

    <?php while($row = mysql_fetch_array($oteaminfo)) { ?>
        <tr>
            <td><?php echo "<a href='cnghlplayers.php?PlayerID=".$row['PlayerID'].">".$row['FullName']."</a>"; ?></td> 
            <td><?php echo $row['Position']; ?></td> 
            <td><?php echo $row['Height']; ?></td> 
            <td><?php echo $row['Weight']; ?></td> 
            <td><?php echo $row['DOB']; ?></td> 
            <td><?php echo $row['Team']; ?></td> 
            <td><?php echo $row['CNGHLRights']; ?></td> 
            <td><?php echo $row['InternationalTeam']; ?></td> 
            <td><?php echo $row['InternationLeague']; ?></td> 
        </tr>
    <?php } ?>
    </table>
<?php //continues your php code below
于 2013-09-01T21:02:20.683 回答