I have a DB query and in the result is [zonrp_cs] (this is a callsign)
I also have a CSV file listing a few callsigns.
I am printing out a table fine, but, when a callsign in the query matches a callsign in the CSV list I want that callsign to be printed as a URL.
Please have a look and tell me where I am going wrong.
Code: Select all
while ($row = pg_fetch_array($result)) {
$last_mod_time = get_time($row['last_mod_time']);
$last_mod_date = get_date($row['mod_date']);
$reg_date = get_date($row['reg_date']);
$callsign = $row['zonerp_cs']; // this is the callsign we will check and display as either plain text or a link.
$cslinked="";
echo '<tr class="trHiLite">';
########################################
#####This part is checking for a match in the CSV #####
########################################
$row = 1;
if (($handle = fopen("cslist.txt", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 10, ",")) !== FALSE) {
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
if ($callsign == $data[$c]){
$cslinked = $callsign; // If $callsign matches an item in the CSV then set $cslinked to equal $callsign and break out.
break;
}
}
}
}
fclose($handle);
########################################
// Now decide how to display our callsigns //
if ($cslinked != $callsign){
echo "<td>$callsign</td>";
}
else{
echo "<td><a href='gateways.php?gateway=$callsign' target='_blank'>$callsign</a></td>";
}
?>
<td><?php echo $last_mod_date;?></td>
<td><?php echo $last_mod_time;?></td>
<td><?php echo $reg_date;?></td>
<!--<td><?php //echo $row['del_flg'];?></td>-->
</tr>
<?php
} // The while loop ends here, lets tidy up and end the script and html.
TIA for any help
Dave