jQuery code:
function sorting(){
$(".search_result_employee").load("include/searchedResult.php", {sort: "SORT_DESC"});
}
php code:
$array = file("data/employees.txt");
$row = intdiv(count($array), 4);
if (count($array)%4 != 0){
$row++;
}
//$row = round(count($array)/4);
$x = $z = 0;
for ($x; $x < $row; $x++){
echo '<div class="row my-4">';
for ($y=0; $y <= 3; $y++){
if (isset($array[$z])) {
$name = explode("| ", $array[$z]);
$eName = $name[0];
$eDepartment = $name[7];
$eProfile = end($name);
echo '
<div class="col-md">
<a href="displayInfo.php?name='."$eName".'" class="grey_bg p-2 m-1 employeeCard">
<img src="employeesProfile/'."$eProfile".'" alt="profile" class="profile"/>
'."$eName".'<br/>
<span>'."$eDepartment".'</span>
</a>
</div>
';
}
$z++;
}
echo '</div>';
}
First go in the page using
<?php include("include/searchedResult.php"); ?>
The page can found the file. Howver, after clicked the button, the jQuery load() the include/searchResu;t.php page. Then, the file doesn't exist. First time is working properly thensecond time can't. Anyone know how to solve this?
this is the error:
Warning: file(data/employees.txt): failed to open stream: No such file or directory in C:\xampp\htdocs\COS30020\include\searchedResult.php on line 14