This codes pulls data from a CSV file and displays them as a table
<?php
$lines = file('graphdata/Dimensions.csv');
foreach ($lines as $lineNum => $line) {
if($lineNum == 0) {
continue;
}
print " <tr id=\"tr" . $lineNum . "\">";
$tokens = str_getcsv($line);
print "<td style=\"width: 200px;\">" . trim($tokens[0]) "</td>";
print "<td style=\"width: 100px;\">" . trim($tokens[1]) . "</td>";
print "</script>\n";
}
?>
The first column is actually an hyperlinked text while the link itself may appear as a cell in the relevant row in the CSV
Is there away to make the text in the first column to appear as hyperlink?
Thanks
General syntax:
echo '<a href="' . $linktTarget . '">' . $linkName . '</a>';
More clear way to do it is just to combain '' and "":
edit: Oh you wanted to whole <td></td>, be the linke, here you go:
<?php
$lines = file('graphdata/Dimensions.csv');
foreach ($lines as $lineNum => $line) {
if($lineNum == 0) {
continue;
}
print '<tr id="tr' . $lineNum . '">';
$tokens = str_getcsv($line);
print '<td style="width: 200px;"><a href="' . trim($tokens[0]) . '">' . trim($tokens[0]) . '</a></td>';
print '<td style="width: 100px;">' . trim($tokens[1]) . '</td>';
print '</script><br />';
}
?>
Also what for is:
print '</script><br />';
at the end?
I have found that the previous way wasn't working in anything other than IE, simplest way to do it across all browsers, is to just add below to your css file:
CSS code:
td a{width:100%;display:block;}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With