$line) $total_lines++; $decade = $_GET['decade']; if ($decade == "") { $decade = '1990'; } $pub_year = $_GET['pub_year']; if ($pub_year == "") { $pub_year = '1990'; } //print "the selected pub year is: " . $pub_year; //opening original file $filename = fopen("mustudent.txt","r"); //reading the file $m=0; for ($i = 0; $i < $total_lines; $i++){ ($data = fgetcsv($filename, 1000, "\t")); $total_fields = count($data); //reading each line (record) $n=0; for($j = 0; $j < $total_fields; $j++){ //assigning values to new_array // print $data[0]; $new_array[$i][$j] = $data[$j]; $temp_year = $data[0]; $just_year = substr($temp_year, 0, 4); // YYYY-MM-DD if ($just_year == $pub_year) { // print $just_year . "/" . $just_month . "Date: " . $new_array[$i][0] . "
"; $display_array[$m][$n] = $data[$j]; $n++; } } $m++; } fclose ($filename); //print_r($display_array); /* print "
". "
"; print_r($display_array); print "
". "
"; print_r($new_array); */ //printing out TOTAL records in mustudent.txt file //print "

This file/collection contains $total_lines lines/records ::: "; $total_rec_display = count($display_array); //print "The year $pub_year contains $total_rec_display records

"; //list of unique YEARS for drop-down menu for ($i = 0; $i < $total_lines; $i++){ $temp_year = $new_array[$i][0]; $just_year = substr($temp_year, 0, 4); $years[$i] = $just_year; } $unique_years = array_unique($years); //print_r($unique_years); sort($unique_years); //print_r($unique_years); //print "
"; //echo max($unique_years); //echo min($unique_years); $max_year = max($unique_years); $decade_fin = substr($max_year, 0, 3) . "9"; // YYYY //print "max_year: " . $max_year . "
"; $min_year = min($unique_years); $decade_inicio = substr($min_year, 0, 3) . "0"; // YYYY //print $decade_inicio; //$decade_fin = $decade_inicio + 9; //print "decade: " . $decade_inicio . "-" . $decade_fin; $decades_with_data = array(); // defining array for unique decades for ($dec_i = $decade_inicio; $dec_i < $decade_fin; $dec_i += 10){ //print $dec_i . "
"; $temporal_decade = range($dec_i, $dec_i + 9); //print_r($temporal_decade) . "
"; foreach ($temporal_decade as $value) { if (in_array($value, $unique_years)) { $decades_with_data[] = $dec_i; //echo "year " . $value . " found for decade " . $dec_i . "
"; } // end in_array //echo ""; } // end of foreach $temporal_decade } // end of for looping all years for populating $decaes_with_data //print_r($decades_with_data); //print "
"; $unique_decades = array_unique($decades_with_data); //print_r($unique_years); sort($unique_decades); //print_r($unique_decades); //print "
"; ?> Miami Student Newspaper Collection

Browse by and

" . $total_rec_display . " issues for this year"; ?>
'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December' ); // the sort function FIXES the index mess for the array with the pub_year variable sort($display_array); //print_r($display_array); for ($mes=1; $mes<=12; $mes++) { echo "
". $months[$mes] . "
"; for ($i = 0; $i < $total_rec_display; $i++){ $temp_year = $display_array[$i][0]; $just_month = substr($temp_year, 5, 2); //print $i . "comparing " . $just_month; if ($mes == $just_month) { //print "" . $display_array[$i][0] . "
"; print "" . $display_array[$i][0]. "
"; } // end print dates for current month } // end for looping current arrary/month echo "
"; } // end if for 1-12 loop ?>