我想弄清楚如何在保持行到位的同时链接表格行中的项目,我有以下代码:
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>";
我尝试过使用
echo "<a href=\"cnghlplayers.php? PlayerID=".$row['PlayerID']."\">".$row['FullName']."<br>";
代替
echo "<td>".$row['FullName']."</td> ";
在表格中但它将链接放在我当前表格上方的新行中。任何帮助将不胜感激,我尝试搜索这个主题,但我找不到任何有用的信息。
谢谢!
答案 0 :(得分:1)
只需将<td>
元素包裹起来:
echo '<td><a href="cnghlplayers.php?PlayerID='.$row['PlayerID'].'">'.$row['FullName'].'</a></td>';
答案 1 :(得分:1)
用TD包裹您的链接:
echo "<td><a href=\"cnghlplayers.php? PlayerID=".$row['PlayerID']."\">".$row['FullName']."</a></td>";
答案 2 :(得分: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