hey guys the checkboxes aren't gettin displayed in the following code and the data isnt gettin stored as well.plz help!!!!!!!

<?php 
    session_start();
    include ("menu.php"); 
$UserId=$_SESSION['UserId'];
?><html>
<head>
<title>Feedback</title>
</head>
<body>
<table>

    <tr>
        <td>
    <form name="f1" method="post" action="Feed2.php">
            <table cellspacing="10">
        <tr>
            <td colspan="2"><h1>Feedback Form</h1></td>
        </tr>


        <tr>
               <td> 
<?php
include ("db.php");

$sql="SELECT  * from student WHERE StudentId = '".$UserId."'";

$result = mysql_query($sql);


while($row=mysql_fetch_array($result))
{
   $name=$row['StudentName'];
   $c=$row['ClassId'];
   echo "NAME:";
   echo $name;
   echo "</br>CLASS:";
   echo $c;

   $sql="select * from class where ClassId='".$c."'";
   $result=mysql_query($sql);
   while($row=mysql_fetch_array($result))
   {
      $d=$row['DeptId'];
      $s=$row['Semester'];
    }

   $sql="select * from subject where DeptId='".$d."' and Semester='".$s."'";

   $result=mysql_query($sql);
    $count=0;
    while($row=mysql_fetch_array($result))
    {

      $sub[$count]=$row['SubjectName'];
      $subid[$count]=$row['SubjectId'];
      $count++; 
      }

  // $sql="select 


   echo "<table border='1'>";
   echo "<tr><th>Question</th>";

   for($i=0;$i<$count;$i++)
   { 
        $sql="Select TeacherId from cst where SubjectId='".$subid[$i]."' AND ClassId='".$c."'";
         $result1 = mysql_query($sql);
        $count1=0;
         while($row=mysql_fetch_array($result1))
         {
               $tea[$count1]=$row['TeacherId'];
               //echo $tea[$count1];
               $count1++;
             }

         echo "<th colspan='".$count1."'>".$sub[$i]."</th>";    
   }
echo "</tr><tr><td></td>";
$tcount=0;
for($i=0;$i<$count;$i++)
   {
    $sql="Select TeacherId,CstId from cst where SubjectId='".$subid[$i]."' AND ClassId='".$c."'";

         //$cstid=$row['CstId'];
         $result1 = mysql_query($sql);
        $count1=0;
         while($row=mysql_fetch_array($result1))
         {
               $tea[$count1]=$row['TeacherId'];
               $cstid[$count1]=$row['CstId'];
               //echo $tea[$count1];
               $count1++;

             }

    for($j=0;$j<$count1;$j++)
    {

                echo "<input type='hidden' id='cstid".$tcount."' name='cstid".$tcount."' value='".$cstid[$j]."'>";
                $tcount++;
             echo "<td>$tea[$j]</td>";
    }
   }



   echo "</tr>";
   $sql="select * from student where ClassId='".$c."' and RollNo>='".$sr."' and RollNo<='".$er."'";
   $result1 = mysql_query($sql);

   $question[1]="Is the teacher enthusiastic about teaching his subject? ";
   $question[2]="Does the teacher explain his subject well? ";
   $question[3]="Is the teacher well prepared for the subject? ";
   $question[4]="Is the speed delivery and clarity of communication good? ";
   $question[5]="Does the teacher encourage the student to participate in the lecture? ";
   $question[6]="Whether the teacher discusses the university Question papers in class? ";
   $question[7]="Is the teacher regular in conducting classes? ";
   $question[8]="Is the discipline of the class maintained?";
   $question[9]="Is the writing on the blackboard neat and well organised? ";
   $question[10]="Does the teacher cover the complete syllabus on time? ";
   $question[11]="Does the teacher compensate for the lost lecture?";
   $question[12]="Is the teacher helpful and punctual in conducting the labratory? ";
   $question[13]="Is the teacher impartial towards all the students? ";
   $question[14]="Is the taecher availavle in the lab during the complete practical session? ";
   $question[15]="Do you like to learn from this teacher in the coming semesters? ";
   $question[16]="Whether the overall rating is 'Good'? ";
   $checkcount=0;
   for($j=1;$j<=16;$j++)
   {
       echo "<tr><td>";
       echo $question[$j];
       echo "</td>";

    for($i=0;$i<$tcount;$i++)
        {
        echo "<td>";
        echo"<input type='checkbox' id='c".$checkcount."' name='c".$checkcount."' checked='true' value='true'/>";

        echo "</td>"; 
        $checkcount++;  
        }
echo "</tr>";

   }
    echo "</table>";

}  
echo "<input type='hidden' id='t1' name='t1' value='$tcount'>";
        echo "<input type='hidden' id='q' name='q' value='16'>";     

mysql_close($con);
?>
</td>


    </tr>
    <tr><td><input type="Submit" value="Submit" onClick="return confirm('Are you sure you want to Submit?')"/></td></tr>
</table>
</form>
        </td>
    </tr>
</table>

</body>
</html>

Recommended Answers

All 2 Replies

perhaps you could check the error for every mysql_query($sql); try inserting
or die(mysql_error()) like mysql_query($sql) or die(mysql_error()

so you could track if there is an error on you query.. cause you put incrementations as you fetch data then as you said there is also no data displayed =)

just try and let us see whats next =)

You do quite a lot of building checkbox code with concatenation of string and with all the quotes you have to take care of you can quickly miss one and the browser won't render correctly. Have you checked the html source (in Firefox: right click on page -> View page source - the possible erros in html code are colored red)?

I prefer this style of constructing HTML code with PHP:

echo"<input type='checkbox' id='c{$checkcount}' name='c{$checkcount}' checked='true' value='true'/>";

I am using PHP's ability to parse variables within quoted strings (curly braces are optional in this case, I used them for clarity). With this style of coding errors are less likely to occur.

Edit: The same goes for constructing queries. The following code is more readable:

$sql="select * from student where ClassId='$c' and RollNo>='$sr' and RollNo<='$er'";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.