为什么文本框不接受任何值?

时间:2016-01-07 15:04:02

标签: php html mysqli

我将文本框的值(由用户插入)保存在变量$ no中。但是当我写一个回声时它并没有显示任何东西。我不明白为什么?

我相信我没有正确插入值。我想要一些帮助。 谢谢。



    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html>
       <head>
          <meta http-equiv="Content-Type"
                 content="text/html; charset=ISO-8859-1" />
          <title>Attendence form</title>
    	  <link type = "text/css" rel = "stylesheet" href = "style.css">
       </head>
       <body>
       <form action = "<?php $_SERVER['PHP_SELF']; ?>" method = "post">
        <table>
    	<tr>
    	 <th>Department</th>
    	 <th>Year</th>
    	 <th>Course</th>
    	 <th>Lecture No</th>
    	 <th>Date</th>
    	</tr>
    	<tr>
    	 <td>
    	  <select name = "dept">
    	   <option value = "cse">CSE</option>
    	   <option value = "eee">EEE</option>
    	  </select>
    	 </td>
    	 <td>
    	  <select name = "year">
    	   <option value = "1st">1st</option>
    	   <option value = "2nd">2nd</option>
    	  </select>
    	 </td>
    	 <td>
    	  <select name = "course">
    	   <option value = "cse2200">CSE 2200</option>
    	   <option value = "cse2201">CSE 2201</option>
    	   <option value = "cse2213">CSE 2202</option>
    	   <option value = "eee2217">EEE 2217</option>
    	   <option value = "math2207">MATH 2207</option>
    	  </select>
    	  </td>
    	  <td>
    	   <input type = "text" name = "days" />
    	  </td>
    	 <td>
    	  <?php echo date("Y/m/d"); ?>
    	 </td>
    	</tr>
    	<tr>
    	 <td></td>
    	 <td></td>
    	 <td></td>
    	 <td>
    	  <input type = "submit" name = "submit" value = "Take attendence" />
    	 </td>
    	 <td>
    	  <input type = "submit" name = "view" value = "View Attendence" />
    	 </td>
    
    	</tr>
    	</table>
    	<hr />
    	<table>
    	 <?php
    	  $year = $_POST['year'];
    	  $dept = $_POST['dept'];
    	  $course = $_POST['course'];
    	  $no = $_POST['days'];
    	  $date = date("Y/m/d");
    	  
    	  echo $days;
    	  if(isset($_POST['submit']) && !isset($_POST['calculate']) && !isset($_POST['view'])){ 
    	    if($year == '1st')
    			 $roll = 1400000;
    		 else if($year == '2nd')
    			 $roll = 1300000;
    		 
    		 if($dept == 'cse')
    			 $roll = $roll + 7000;
    		 else if($dept == 'eee')
    			 $roll = $roll + 3000;
    	  $i = 1;
    	  echo '<tr><th>Attendence Form:</th></tr>';
    	  while($i <= 10){
    		  $roll = $roll + 1;
    		  echo '<tr> <td> <input type = "checkbox" value = "'. $roll . '" name = "present[]">'.$roll.'</input> </td></tr>';
    		  $i++;
    	    }
    	  ?>
         <td>
    	  <input type = "submit" name = "calculate" value = "Calculate" />
    	 </td>
    	 <?php 
    	  }
    	  else if(isset($_POST['calculate'])){
    		  $dbc = mysqli_connect('localhost', 'root', '', 'rankodatabase')
    			or die('Error connecting database');
    		  foreach($_POST['present'] as $p){
    			  $query1 = "SELECT * FROM attendence WHERE roll = '$p' AND course = '$course'";
    			  $result1 = mysqli_query($dbc, $query1)
    				or die('Error in select query1');
    			  $p_days = 0;
    			  while($row = mysqli_fetch_array($result1)){
    				  $p_days++;
    				  echo 'roll'. $row['roll'] . ' course' . $row['course'] . ' date' . $row['date'] . ' percentage' . $row['percentage'] . '<br />';
    			  }
    			  
    			  echo 'Lecture' . $no;
    			  /*$percentage = ($p_days / $no_of_lecture) * 100;
    			  $query2 = "INSERT INTO attendence VALUES('$p', '$course', '$date', '$percentage')";
    			  $result2 = mysqli_query($dbc, $query2)
    				 or die('Error in insert query2'); */
    		  }
    		  //$query = "INSERT INTO attendence VALUES('"
    	  }
    
    	  ?>
    	</table>
    	</form>
       </body>
     </html>
&#13;
&#13;
&#13;

0 个答案:

没有答案