Hello,
This is my first time posting here and it may sound like a weird/stupid question, but I feel completely lost right now ! Please give me a hand !
I want to have on my website a dynamic page where one can consult information about people registered in a SQL table, preferably in an ergonomic fashion.
Here is what I’d like :
6093
On the left, this is a list of people that are in my table. I want to display on the right information about one person when the user clicks on him in the list on the left.
In order to achieve this, I tried to use the following jquery script: (called on click on any of the names on the left)
web\js\showStudent.js
function showStudent(str) {
if (str == "") {
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest) { // IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // IE5 & 6
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "phpscripts/getstudent.php?q=" + str, true);
xmlhttp.send();
}
This part worked out well, except when I try to call this external php script:
web\phpscripts\getstudent.php
<?php
use yii\helpers\Html;
use yii\widgets\LinkPager;
use yii\data\Pagination;
use yii\db\Query;
$q = intval($_GET['q']);
$queryAS = (new Query())
->select('*')
->from('answer_series')
->where(['id_student' => $q]);
$pagination = new Pagination([
'defaultPageSize' => 10,
'totalCount' => $query->count(),
]);
$myAS = $query->offset($pagination->offset)
->limit($pagination->limit)
->all();
$queryPS = (new \yii\db\Query())
->select('*')
->from('problem_series');
$myPS = $queryPS->all();
?>
<ul>
<?php foreach ($myPS as $PS):
foreach ($myPA as $PA):
if ($PS['id'] == $PA['id_problem_serie']): ?>
<li>
<?= Html::encode("{$PS->name}") ?>
</li>
<?php endif;
endforeach;
endforeach; ?>
<?= LinkPager::widget(['pagination' => $pagination]) ?>
</ul>
I get the following error for each yii class I try to use in my php script:
[Tue Nov 18 13:51:00.057269 2014] [:error] [pid 21178] [client ::1:47118] PHP Fatal error: Class 'yii\\db\\Query' not found in /local/vanneste/public_html/basic/web/phpscripts/getstudent.php on line 9, referer: localhost/~vanneste/basic/web/index.php?r=teacher%2Fdashboard
At this point I didn’t have any clue anymore of what was going on… Is this even the correct way to make a dynamic page like the one I’d like ? What am I not understanding ?
Thank you so much for helping me out !