Jump to content

Guest can not see content


Sergei
 Share

Recommended Posts

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>";
 }?>

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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?

  • Like 3
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...