Search code examples
phpurlhtml-tablegenome

Add a hyperlink to each entry of a table from mysqli


I'm trying to add a direct link to the genomic region of each gene on a table generated with mysqli data, but can't figure out the way. The idea is that every gene name has a hyperlink to it's region on a genome browser.

The problem comes when I have to generate the link dynamically for each gene depending on the gene selected by the user.

I've tried this:

echo '<td><a href="http://genome.ucsc.edu/cgi-bin/hgTracks?"'.urlencode($genome.$row['name2'])'>'$row['name2']'</a></td>';

$genome is the par of the url specific for each species and assembly, and $row['name2'] is the name of each gene.


Solution

  • You had your quote double quote in wrong location if there are additional problems will need more info

        // Yours
    echo '<td><a href="http://genome.ucsc.edu/cgi-bin/hgTracks?"'.urlencode($genome.$row['name2'])'>'$row['name2']'</a></td>'
    // Fixed Quote
    echo '<td><a href="http://genome.ucsc.edu/cgi-bin/hgTracks?'.urlencode($genome.$row['name2'])'">'$row['name2']'</a></td>';