I am trying to make a database.txt ref into href links on page ONLY if there is a http site in database.
The link would be underlined if there was a corresponding entry into database.txt file.
Does that make sense?? Here is the current code --
<?php
$filename = "../database.TXT";
$delimiter = ",";
$filePointer = fopen($filename, "r");
$state = strtoupper($state);
$k = 0;
$bool = 0;
while (!fEof ($filePointer) ) {
$line = fgets($filePointer, 4096);
$fields = explode($delimiter,$line);
$j = 0;
foreach ($fields as $i) {
$i = explode('"',$i);
if($i[1]) {
$fields[$j] = $i[1];
}
$j++;
odd that this isn't the same as the table # echo "j-$j value: $fields[$j]<br>";
}
if ($fields[8]) {
$company_name = "$fields[0]";
}
else {
$company_name = "$fields[0]";
}
if ($fields[9]) {
$web = "<a href=http://$fields[9]>Web</a>";
}
else {
$web = "$fields[9]";
}
if($k != 0) {
if($state) {
if($state == $fields[6]) {
echo "<tr $bool> <td>$company_name</td> <td>$fields[2]</td><td>$fields[5]</td> <td>$fields[6]</td> </tr>\n";
}
}
else {
echo "<tr $bool> <td>$company_name</td> <td>$fields[2]</td> <td>$fields[5]</td><td>$fields[6]</td> </tr>\n";
}
}
$k++;
if($bool) {
$bool = 0;
}
else {
$bool = 'bgcolor="#CCCCCC"';
}
}
}
?>
I tried this but all I got was that every company name was underlined whether or not there was a link or not ---
<?php
$filename = "../database.TXT";
$delimiter = ",";
$filePointer = fopen($filename, "r");
$state = strtoupper($state);
$k = 0;
$bool = 0;
while (!fEof ($filePointer) ) {
$line = fgets($filePointer, 4096);
$fields = explode($delimiter,$line);
$j = 0;
foreach ($fields as $i) {
$i = explode('"',$i);
if($i[1]) {
$fields[$j] = $i[1];
}
$j++;
odd that this isn't the same as the table # echo "j-$j value: $fields[$j]<br>";
}
if ($fields[8]) {
$company_name = "$fields[0]";
}
else {
$company_name = "$fields[0]";
}
if ($fields[9]) {
$web = "<a href=http://$fields[9]>Web</a>";
}
else {
$web = "$fields[9]";
}
if($k != 0) {
if($state) {
if($state == $fields[6]) {
echo "<tr $bool> <td><a href=http://$fields[9]>$company_name</a></td> <td>$fields[2]</td><td>$fields[5]</td> <td>$fields[6]</td> </tr>\n";
}
}
else {
echo "<tr $bool> <td><a href=http://$fields[9]>$company_name</a></td> <td>$fields[2]</td> <td>$fields[5]</td><td>$fields[6]</td> </tr>\n";
}
}
$k++;
if($bool) {
$bool = 0;
}
else {
$bool = 'bgcolor="#CCCCCC"';
}
}
}
?>
Thank for any and all help.
djp