andrew andrew - 1 month ago 7
HTML Question

Hyperlink returned results from one column to another column

This project is essential a catalog of past projects/designs that I use at work. Currently it puts the clickable link to a PDF of the proof file in the Link column and labels them all "PDF". I'd like to change the output to make the "Client Name" column clickable, and their hyperlinks direct to the PDFs from the Link column instead. I believe I've located the correct section in the code to modify, but how do I print the returned value for the Link column PDF, as a hyperlink, using the returned value for the Client Name column as its plain text name? Here is the section of code I suspect needs to be modified, and then there is a screenshot of how it looks now. Any pointers on what direction I could take would be greatly appreciated!

The Code:

$registrantList = '';
$sql = "SELECT Client, Product, Market, Type, Date, Category, Disc, Link, Notes FROM designarchive ORDER BY $sql_orderBy";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$registrantList .= '<tr><td>' . htmlentities($row['Client']) . '</td><td>' . htmlentities($row['Product']) . '</td><td>' . htmlentities($row['Market']) . '</td><td>' . htmlentities($row['Type']) . '</td><td>' . htmlentities($row['Date']) . '</td><td>' . htmlentities($row['Category']) . '</td><td>' . $row['Disc'] . '</td><td><a href="' . $row['Link'] . '">PDF</a></td><td>' . htmlentities($row['Notes']) . '</td></tr>';
}


The Screenshot:
the screenshot

Answer

Change the line to this:

$registrantList .= '<tr><td><a href="' . $row['Link'] . '">' . htmlentities($row['Client']) . '</a></td><td>' . htmlentities($row['Product']) . '</td><td>' . htmlentities($row['Market']) . '</td><td>' . htmlentities($row['Type']) . '</td><td>' . htmlentities($row['Date']) . '</td><td>' . htmlentities($row['Category']) . '</td><td>' . $row['Disc'] . '</td><td>' . htmlentities($row['Notes']) . '</td></tr>';