Brian J Kirk
Brian J Kirk

Reputation: 61

linking an item in table using php

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!

Upvotes: 0

Views: 62

Answers (3)

Austin
Austin

Reputation: 124

Test this, there were some issues with your table markup. This should be a bit easier to read as well.

?> <!-- 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

Upvotes: 1

Alex
Alex

Reputation: 1593

Wrap your link with TD:

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

Upvotes: 1

Tobias Golbs
Tobias Golbs

Reputation: 4616

Just wrap the <td> element around:

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

Upvotes: 1

Related Questions