Nie jest to cały kod. search_result.html to tylko plik html/php z pewnymi skryptami javy, które umożliwiają np. edycję pobranych danych i wysyłanie ich ponownie tam, skąd zostały pobrane. Natomiast za tworzenie tej tabeli odpowiedzialna jest inna funkcja, chyba jest to ta funkcja (tzn. za wyświetlanie tych 10 wyników, sortowanie ich, wybieranie z listy rozwijanej tylko wybranych danych, etc.).
plik nazywa się modules.php i jest to jedna z wielu zawartych w nich funkcji. Pokażę wszystkie, które moim zdaniem mogą być wywoływane do wyświetlania tabeli:
...
public function GetConnectionTab($column, $table){
$sql = 'SELECT DISTINCT '.$column.' FROM '.$table;
$Res = $this->DB->run($sql);
foreach($Res as $v){
$Tab[] = $v[$column];
}
return $Tab;
}
...
public function Select($from, $whe = '', $fields = '*'){
$Res = $this->DB->select($from, $whe, '', $fields);
return $Res;
}
...
public function SelectSingle($from, $whe = '', $fields = '*'){
$R = $this->Select($from, $whe, $fields);
return (isSet($R[0
])) ?
$R[0
] : null; }
...
public function GetResults(){
return $this->GetTable($this->table);
}
public function GetPassesTable(){
$Result = $this->DB->select('userpermissions up, results r, subjects sb, classestypes ct, employees e, students st, passes ps', 'up.user_id = '.$this->User->GetID().' AND up.course_id = r.course_id AND sb.subject_id = r.subject_id AND ct.classestype_id = r.classestype_id AND e.employee_id = r.employee_id AND st.student_id = r.student_id AND st.student_id=ps.stutend_id ORDER BY r.pass', 'r.*, ps.*');
return $Result;
} //OWA FUNKCJA, RACZEJ NIE WPŁYWA NA WYŚWIETLANE DANE, PONIEWAŻ ZAKOMENTOWANIE PODOBNYCH DLA INNYCH TABEL NIE WPŁYWA NA TO CO WYŚWIETLA SIĘ W TABELI PLIKU WYNIKOWEGO search_results.html
...
public function GetTable($TableName, $Where = ''){
if($this->User->GetPermission() == '99' || '25'){ //25 dodane aby wyświetlała się zawartośc modułu PASSES dla EMPLOYEE
switch($TableName){
case 'passes' : $Result = ($Where != '') ? $this->DB->select($TableName, $Where) : $this->DB->select($TableName); break;
case 'employees' : $Result = ($Where != '') ? $this->DB->select($TableName, $Where.' ORDER by last_name') : $this->DB->select($TableName, ' 1 = 1 ORDER By last_name'); break;
case 'classes' : $Result = ($Where != '') ? $this->DB->select($TableName, $Where) : $this->DB->select($TableName); break;
case 'users' : $Result = ($Where != '') ? $this->DB->select($TableName, $Where) : $this->DB->select($TableName); break;
case 'logs' :$Result = ($Where != '') ? $this->DB->select($TableName, $Where) : $this->DB->select($TableName); break;
default : $Result = ($Where != '') ? $this->DB->select($TableName, $Where.' ORDER by name') : $this->DB->select($TableName, ' 1 = 1 ORDER By name'); break;
}
} else {
switch($TableName){
case 'passes' : $Result = $this->GetPassesTable(); break; //TABELA PASSES
case 'courses' : $Result = $this->GetCoursesTable(); break;
case 'units' : $Result = $this->GetUnitsTable(); break;
case 'specialties' : $Result = $this->GetSpecialtiesTable(); break;
case 'subjects' : $Result = $this->GetSubjectsTable(); break;
case 'classes' : $Result = $this->GetClassesTable(); break;
case 'employees' : $Result = $this->GetEmployeesTable(); break;
case 'students' : $Result = $this->GetStudentsTable($Where); break;
default : $Result = ($Where != '') ? $this->DB->select($TableName, $Where) : $this->DB->select($TableName);
}
}
return $Result;
}
...
public function RewriteTable($Table, $LabelID){
foreach($Table as $row){
$NewArray[$row[$LabelID]] = $row;
}
return $NewArray;
}
...
public function RewriteSpecialTable($Table, $LabelID1, $LabelID2){
foreach($Table as $row){
$Label = $row[$LabelID1].$row[$LabelID2];
$NewArray[$Label] = $row;
}
return $NewArray;
}
...
public function RewriteSpecialDashTable($Table, $LabelID1, $LabelID2){
foreach($Table as $row){
$Label = $row[$LabelID1].'_'.$row[$LabelID2];
$NewArray[$Label] = $row;
}
return $NewArray;
}
Wydaje mi się, że w tej funkcji leży problem, ponieważ nie pobieram przecież tylko tabeli passes, ale i dane z tabeli classes. Pokażę jeszcze strukturę tych dwóch tabel dla jasności:
CLASSES
CREATE TABLE IF NOT EXISTS `classes` (
`class_id` int(11) NOT NULL AUTO_INCREMENT,
`subject_id` int(11) NOT NULL,
`year_id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`classestype_id` int(11) NOT NULL,
PRIMARY KEY (`class_id`)
);
PASSES
CREATE TABLE IF NOT EXISTS `passes` (
`pass_id` int(11) NOT NULL AUTO_INCREMENT,
`class_id` int(11) NOT NULL,
`student_id` int(11) NOT NULL,
`pass` enum('0','2','3','3.5','4','4.5','5','ZAL') COLLATE utf8_polish_ci DEFAULT '0',
`pass_date` varchar(256) COLLATE utf8_polish_ci NOT NULL,
`comments` varchar(100) COLLATE utf8_polish_ci DEFAULT NULL,
PRIMARY KEY (`pass_id`)
);
Jak widać tabela classes w zupełności wystarcza mi do wyświetlania wyników. Zapytanie, które przedstawiłem na początku wyświetla przykładowo następujące dane:
ZAJĘCIA1 - PRZEDMIOT1 - PROWADZĄCY 1 - RODZAJ ZAJĘC 1 - STUDENT 1 - OCENA/DATA/KOM
ZAJĘCIA2 - PRZEDMIOT1 - PROWADZĄCY 1 - RODZAJ ZAJĘC 2 - STUDENT 1 - OCENA/DATA/KOM
ZAJĘCIA1 - PRZEDMIOT1 - PROWADZĄCY 1 - RODZAJ ZAJĘC 1 - STUDENT 2 - OCENA/DATA/KOM
ZAJĘCIA2 - PRZEDMIOT1 - PROWADZĄCY 1 - RODZAJ ZAJĘC 2 - STUDENT 2 - OCENA/DATA/KOM
I tak dalej. Z reguły z jednego przedmiotu są 2 rodzaje zajęć: wykład i ćwiczenia, dlatego dla każdego studenta wyświetla dwa rekordy. Wszystkie te informacje pobieram z tabeli classes, łącząc ją z innymi tabelami poprzez id i do tego doklejam tabelę passes.