php - Why isn't the textbox accepting any value? -
i keeping value(inserted user) of text box in variable $no. not showing when write echostatement. don't understand why??
i believe not inserting value properly. help. thank you.
<!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'] $p){ $query1 = "select * attendence roll = '$p' , 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 attendence values('$p', '$course', '$date', '$percentage')"; $result2 = mysqli_query($dbc, $query2) or die('error in insert query2'); */ } //$query = "insert attendence values('" } ?> </table> </form> </body> </html>
Comments
Post a Comment