I have a column in a DB that populates a list within a table of the top gaining athletes on my fantasy sports website, on the website I would like to be able to have “Jamal Charles” be a url and have it linked to the internal webpage for Jamaal that was already created. below the table I have the function that is calling the “companyname” – companyname is actually the athletes name.
How would I make the “companyname” a link to its own page in this table? Would i make another function that calls the url instead? Make another column that accepts urls and call that? I hear that sometimes the database will only echo the url text and not make it a link. Is any of the possible?
Please let me know if you need more code. Thanks in advance everyone!
Top Gaining Athletes Today
1. Jamaal Charles 0.54 %
2. Kyle Rudolph 0.50 %
3. A.J. Green 0.48 %
4. Michael Bush 0.48 %
5. Jared Cook 0.47 %
6. Christian Ponder 0.45 %
7. Alfred Morris 0.45 %
8. Nate Washington 0.44 %
9. Ryan Succop 0.44 %
10. DeMarco Murray 0.43 %
function getTopAthletes($connection){
$i=1;
$query = "SELECT b. companyname, (a.currentprice - a.open)/a.open as performance FROM jm_market a, jm_stocks b WHERE a.symbol = b.symbol AND active = 'Y' ORDER BY performance desc LIMIT 10";
$result=mysql_query($query,$connection) or die('Problem with obtaining top PLAYERS: ' . $query);
$output = "<table class='tab1 bborder' cellspacing='0'>";
$output.= "<th colspan='4'>Top Gaining Athletes Today</th>";
while($row=mysql_fetch_array($result)){
// Shorten really long names
if (strlen($row['companyname']) > 20) {
$short = split (' ', $row['companyname']);
$row['companyname'] = substr( $short[0],0,1 ) . ". ";
unset($short[0]);
foreach ($short as $n) {
$row['companyname'] .= $n . " ";
}
$row['companyname'] = rtrim($row['companyname']);
}
$output .="<tr ><td width='20px'><strong>" . $i.".</strong></td>";
$output .="<td ><strong>" . $row['companyname']."</strong></td>";
$output .="<td><strong>" . number_format(($row['performance']) * 100,2)." %</strong></td></tr>";
$i++;
}
$output .= "</table>";
return $output;
}
Try this
That should give you