need some help with retrieving and displaying data
Posted: Tue Apr 20, 2010 1:03 pm
[text]I have set up a online course and testing module for my students using Moodle (similar to blackboard)
There is a daily question (one for each day of the year).
The user logs in , goes to a screen that shows the user a calendar.
A php script runs which checks which dates the student has completed.
If they have done that day, I want an X to be inserted into the cell for that day.
An example of the php script is included below. Php is still new to me so I could be violating some rule or something
but I have gone round and round and cant seem to find what I am doing wrong.
I have been going at this problem for about a week now and seem to be getting hung up on something I'm missing.
I've flipped through the manual and google enough times to recognize I'm just going in circles around the answer that should probably
be self evident by now but I can't seem to see the forest through the trees....
{/text]

There is a daily question (one for each day of the year).
The user logs in , goes to a screen that shows the user a calendar.
A php script runs which checks which dates the student has completed.
If they have done that day, I want an X to be inserted into the cell for that day.
An example of the php script is included below. Php is still new to me so I could be violating some rule or something
but I have gone round and round and cant seem to find what I am doing wrong.
I have been going at this problem for about a week now and seem to be getting hung up on something I'm missing.
I've flipped through the manual and google enough times to recognize I'm just going in circles around the answer that should probably
be self evident by now but I can't seem to see the forest through the trees....
{/text]
Code: Select all
<?php
require_once("../../config.php");
require_once("locallib.php");
//Force the user to login if he already has not done so
require_login($course->id, false, $cm);
function Checker($arg)
{
include '../../mydbconfigdata.inc';
$con = mysqli_connect($host, $user, $password, $dbname') or die (mysql_error());
$sql = "SELECT *
FROM mdl_quiz_attempts
INNER JOIN mdl_quiz
ON mdl_quiz.id = mdl_quiz_attempts.quiz
WHERE mdl_quiz_attempts.userid = $USER->id
AND mdl_quiz_attempts.sumgrades = 1
ORDER BY mdl_quiz_attempts.quiz";
echo $arg;
$result = mysqli_query($con,$sql) or die(mysql_error());
if (mysqli_num_rows($result))
{
While ($row=mysqli_fetch_row($result))
{
if (stristr($row[11], $arg))
{
echo "X";
}
}
}
else
{
echo 'No Data Available';
}
}
?>
<html>
<head></head>
<body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
<div class=Section1>
<p class=MsoNormal align=right style='text-align:right'><i style='mso-bidi-font-style:normal'><span style='font-size:14.0pt;color:blue'>
<?php
echo "You are logged in as ", $USER->firstname, " ", $USER->lastname;
?>
<o:p></o:p></span></i></p>
/////// more html to create a calendar here...........................................
///////Skip down to January 1
///////Cell for Jan 1
<span style='mso-bookmark:OLE_LINK1'></span>
<td nowrap valign=bottom style='border-top:none;border-left:none;border-bottom:
solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-bottom-alt:
solid windowtext .5pt;mso-border-right-alt:solid windowtext .5pt;background:
#CCCCFF;padding:.75pt .75pt 0in .75pt;height:4.15pt'
onclick="window.location.href='http://www.mywebsite.com/moodle/mod/quiz/attempt.php?id=396'">
<p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span
style='mso-bookmark:OLE_LINK1'>
<?php
//Calls the function Checker to put an x in Jan 1 box if question has been answered.
echo Checker(1);
?>
<o:p></o:p></span></p>
</td>
///////Cell for Jan 2
<span style='mso-bookmark:OLE_LINK1'></span>
<td nowrap valign=bottom style='border-top:none;border-left:none;border-bottom:
solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;mso-border-bottom-alt:
solid windowtext .5pt;mso-border-right-alt:solid windowtext .5pt;background:
#CCCCFF;padding:.75pt .75pt 0in .75pt;height:4.15pt'
onclick="window.location.href='http://www.mywebsite.com/moodle/mod/quiz/attempt.php?id=397'">
<p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span
style='mso-bookmark:OLE_LINK1'>
<?php
//Calls the function Checker to put an x in Jan 2 box if question has been answered.
echo Checker(2);
?>
<o:p></o:p></span></p>
</td>
///////etc, etc, etc. until done with calendar.
</body>
</html>