I have a table on my website, that I based on this script.
I have my data in a csv. The code outputs the data straight onto the table. On the third column I have either 1,2,3, or 4. I want to replace the cells in that column with one of four images, depending on the number.
If anyone could help, I would be very appreciative. 😃
Also:
The second column has a list of names. How can I make them links depending on the name, with all the capitals removed? For example. There are three names: Bob, Bill, and Samantha
The data in the column should be:
<a href="bob.zip">Bob</a>
<a href="bill.zip">Bill</a>
<a href="samantha.zip>Samantha</a>
EDIT: Here's some of the code if it helps.
$sortby = $_SERVER['QUERY_STRING'];
$set = '';
if ($sortby == '') {
$header = '
<li class="selected"><a href="index.php">numb.</a></li>
<li><a href="?name">name.</a></li>';
$sortby = 'numb';
$set = 'y';
}
if ($sortby == 'name') {
$header = '
<li><a href="index.php">numb.</a></li>
<li class="selected"><a href="index.php?name">name.</a></li>';
$set = 'y';
}
if ($set == '') {
echo 'The variable at the end of the web address did not match one required by the code. Please check the web address for errors.';
exit;
}
$fp = fopen('database.csv','r');
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}
while (!feof($fp)) {
$line = fgets($fp,1024); //use 2048 if very long lines
$row++;
list ($numb, $name, $generation) = split ('\,', $line);
if ($sortby == 'numb') $sortkey = strtolower($numb);
if ($sortby == 'name') $sortkey = strtolower($name);
$col[$row] = array($sortkey, $numb, $name, $generation);
}
fclose($fp);
sort($col);
reset ($col);
$arrays = count($col) - 1;
$loop = -1;
while ($loop < $arrays) {
$loop++;
echo '
<tr>
<td>'.$col[$loop][1].'</td>
<td>'.$col[$loop][2].'</td>
<td>'.$col[$loop][3].'</td>
</tr>';
}
?>