My title is way over simplified compared to what I am actually looking to do.
First, I have a csv file that has 1300+ lines of data. One of the tables in the csv file is "Categories" and each of the 1300+ lines falls into one of about 20 categories. What I need is to pull each category name from the csv file, in a non-case sensitive manner, and have them displayed on a page that when clicked on would then list all of the lines from the csv file that fall under that category with that categories name displayed at the top of the page. And no matter which category is clicked on the first row of the csv file, which has each tables name, needs to be displayed also.
Second, I also need to take the above mention first row, which has headings for five tables, and make it so that the headings can be clicked on and change how everything that is displayed in that particular category is sorted. The first click would sort in ascending order the second click would sort in descending order. I also need each category starting out to be sorted by the first table called "Title" in ascending order but if clicked on would change to descending order.
I know a MySQL database would be easier but the people I am doing this for are, for this year, locked into a web host that only gives you a MySQL database if you pay more. And since the present database isn't in MySQL they are hoping that they can make everything work till next year.
I am not even sure if what I am asking is possible I am hoping that someone has some good ideas at least on doing the second part if not both. I have been searching this forum and have read almost everything on php.net that has to do with sorting, in the last couple of days, and have not found much of anything that could give me a realistic idea of how to do this. I have been working on this so much that when I took a nap this afternoon (because I got up way to early this morning) I dreamed of sort, usort, whateversort, and php code, it's more like a nightmare.
Just so there is some frame of reference as to what I am doing I have included, below, the code I am using at presently to display the csv file.
<?
$filename = "ecgcdata.csv";
$id = fopen($filename, "r");
while ($data = fgetcsv($id, filesize($filename), "|"))
{
$file_array[] = $data;
}
$row = 0;
while (list(, $value) = each($file_array))
{
$row++;
if ($row == 1)
{
echo '<tr>';
echo '<td id="tdoc" class="doc1">' . $value[0] . '</td>';
echo '<td id="tdoc" class="doc1">' . $value[4] . '</td>';
echo '<td id="tdoc" class="doc1">' . $value[6] . '</td>';
echo '<td id="tdoc" class="doc1">' . $value[2] . '</td>';
echo '</tr>';
}
if ($row == 2)
{
echo '<tr>';
echo '<td id="ldoc" class="doc2">' . $value[0] . '</td>';
echo '<td id="ldoc" class="doc2">' . $value[4] . '</td>';
echo '<td id="ldoc" class="doc2">' . $value[6] . '</td>';
echo '<td id="ldoc" class="doc2">' . $value[2] . '</td>';
echo '</tr>';
}
if ($row == 3)
{
echo '<tr>';
echo '<td id="ldoc" class="doc1">' . $value[0] . '</td>';
echo '<td id="ldoc" class="doc1">' . $value[4] . '</td>';
echo '<td id="ldoc" class="doc1">' . $value[6] . '</td>';
echo '<td id="ldoc" class="doc1">' . $value[2] . '</td>';
echo '</tr>';
$row = 1;
}
}
?>