Sergei Posted March 1, 2017 Posted March 1, 2017 Hi please help to solve the problem. I'm trying to parse csv on the page, but not in the database. Under administrator all get the script working, for the rest is not. <?php if ($page->mo){ echo"<div class=\"table-responsive m20tb\"><table class=\"table table-striped table-bordered sm\"> <th>Ф.И.О.</th><th>Должность</th><th>Преподаваемые дисциплины</th><th>Направление подготовки и (или) специальности</th><th>Повышение квалификации</th><th>Общий стаж работы</th><th>Стаж работы по специальности</th><th>Ученая степень</th><th>Ученое звание</th>"; foreach($page->mo as $mo){ $n++; $mo->isFirst = ($n === 1); $mo->isLast = ($n === $total); if($mo->folder){ chdir('/home/admin/web/pw.loc/public_html/data/thicher/'); $f = fopen("{$mo->folder}", "r"); while (($line = fgetcsv($f)) !== false) { $id= $line[0]; $name= $line[1]; $dolg= $line[2]; $disc= $line[3]; $napr= $line[4]; $kat= $line[5]; $cval= $line[6]; $ost= $line[7]; $pst= $line[8]; $uch_s= $line[9]; $uch_z= $line[10]; $reg_z= $line[11]; $foto= $line[12]; echo "<tr><td itemprop=\"fio\">" . htmlspecialchars($name) . "</td><td itemprop=\"Post\">" . htmlspecialchars($dolg) . "</td> <td itemprop=\"TeachingDiscipline\">" . htmlspecialchars($disc) ."</td> <td itemprop=\"EmployeeQualification\" >" . htmlspecialchars($napr) ."</td> <td itemprop=\"ProfDevelopment\">" . $cval ."</td> <td itemprop=\"GenExperience\">" . htmlspecialchars($ost) ."</td> <td itemprop=\"SpecExperience\">" . htmlspecialchars($pst) ."</td><td itemprop=\"Degree\">" . htmlspecialchars($uch_s) ."</td><td itemprop=\"AcademStat\">" . htmlspecialchars($uch_z) ."</td></tr>"; } fclose($f); } } echo"</table></div>"; }?>
Macrura Posted March 2, 2017 Posted March 2, 2017 maybe you need to check count of $page->mo, since it appears to be an array field? <?php if(count($page->mo)) { echo " <div class=\"table-responsive m20tb\"> <table class=\"table table-striped table-bordered sm\"> <thead> <th>Ф.И.О.</th> <th>Должность</th> <th>Преподаваемые дисциплины</th> <th>Направление подготовки и (или) специальности</th> <th>Повышение квалификации</th> <th>Общий стаж работы</th> <th>Стаж работы по специальности</th> <th>Ученая степень</th> <th>Ученое звание</th> </thead><tbody>"; $n = 0; foreach($page->mo("check_access=0") as $mo) { $n++; $mo->isFirst = ($n === 1); $mo->isLast = ($n === $total); if($mo->folder) { chdir('/home/admin/web/pw.loc/public_html/data/thicher/'); $f = fopen("{$mo->folder}", "r"); while(($line = fgetcsv($f)) !== false) { $id = $line[0]; $name = $line[1]; $dolg = $line[2]; $disc = $line[3]; $napr = $line[4]; $kat = $line[5]; $cval = $line[6]; $ost = $line[7]; $pst = $line[8]; $uch_s = $line[9]; $uch_z = $line[10]; $reg_z = $line[11]; $foto = $line[12]; echo "<tr> <td itemprop=\"fio\">" . htmlspecialchars($name) . "</td><td itemprop=\"Post\">" . htmlspecialchars($dolg) . "</td> <td itemprop=\"TeachingDiscipline\">" . htmlspecialchars($disc) ."</td> <td itemprop=\"EmployeeQualification\" >" . htmlspecialchars($napr) ."</td> <td itemprop=\"ProfDevelopment\">" . $cval ."</td> <td itemprop=\"GenExperience\">" . htmlspecialchars($ost) ."</td> <td itemprop=\"SpecExperience\">" . htmlspecialchars($pst) ."</td> <td itemprop=\"Degree\">" . htmlspecialchars($uch_s) ."</td> <td itemprop=\"AcademStat\">" . htmlspecialchars($uch_z) ."</td> </tr>"; } fclose($f); } // END IF MO->FOLDER } // END FOREACH echo "</tbody></table></div>"; } // END IF
Sergei Posted March 2, 2017 Author Posted March 2, 2017 It does not work under the table displayed by the administrator, guest - no
Macrura Posted March 2, 2017 Posted March 2, 2017 if $page->mo is a repeater, then you need to do $page->mo("check_access=0")
Sergei Posted March 2, 2017 Author Posted March 2, 2017 yes mo repeater foreach($page->mo("check_access=0") as $mo){ ...... does not work
Macrura Posted March 2, 2017 Posted March 2, 2017 do you have TracyDebugger installed? you probably need to walk through the code and bd() or l() some variables and such until you can see what is failing. you might want to try bd($mo->folder); bd($f); in their respective locations to see if they are failing; what is $mo->folder? 3
Sergei Posted March 3, 2017 Author Posted March 3, 2017 Thank you so much for helping figured out accidentally restricted access rights $mo->folder ))).
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now