backend.php
Created Thursday 21 July 2022
<?php /* * */ require_once('./classes.php'); $storage_file = "./storage.txt"; unset($file_handle); $subject_array = array(); $csvfile = fopen($storage_file,'r'); while(!feof($csvfile)) { $allfields[] = fgetcsv($csvfile); } /* allfields is technically an array of arrays; specifically, a "super-array" that has read each row of the file, and dropped each element (separated by commas) into an array * */ $subject_array = array(); foreach($allfields as $fieldrrow){ $currsub = new subject(); $currsub->setFirstname($fieldrrow[0]); $currsub->setLastname($fieldrrow[1]); $currsub->setAge($fieldrrow[2]); $currsub->setIncome($fieldrrow[3]); /* remember this isn't an overwrite, this ADDS a new subject Object to the end of the already existing array */ $subject_array[] = $currsub; } /* okay the report */ $record_number = 1; foreach ($subject_array as $newsubject) { echo "<br>"; echo "<h1> Record number $record_number <h1>"; echo "<h2> Subject name:</h2>"; echo $newsubject->getFirstname(); echo " "; echo $newsubject->getLastname(); echo " "; echo "Age - " . $newsubject->getAge(); echo "\n"; echo " Income - " . $newsubject->getIncome(); echo "\n"; echo " SUBJECT CODE: " . $newsubject->agetocolor() . " " . $newsubject->incometofood(); $record_number++; }
Backlinks: FSU Courses:LIS5367:Older Material:flat cronut