if it is possible that for eg: Retrieve seat numbers sql tables bases of some conditions eg batch semester and degree if i search batch 2008 , semester first and degree bscs then search seat numbers then enter these marks mid term, terminal and lab marks then insert these data (batch, semester, degree, seat numbers and marks of mid, lab, terminal) in another table. i am trying these but not successful, A problem occur that when seat numbers more then one problem generates how insert multiple values in mysql through text fields. i am using batch,semester and degree onchange event in ajax
entermarks.php
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="mystyle.css" rel="stylesheet" type="text/css"> <script language="javascript" src="enter_marks.js"></script> </head> <body> <h1>Enter Marks Of Students</h1> <form name="fm" action="enter_marks.php" method="get" > <table width="288" border="0"> <tr><td width="290"> <div align="left"><strong>Teacher</strong> : <select name="teacher" onChange="getCourse(this.value);getCourse(document.fm.teacher.selectedIndex);"> <option value="">Select Teachers</option> <option value="Dr. Husan Afroze Rizvi">Dr. Husan Afroze Rizvi</option> <option value="Ms. Talat Syeda">Ms. Talat Syeda</option> <option value="Ms. Farah Tariq">Ms. Farah Tariq</option> <option value="Dr. Afshan Wasti">MDr. Afshan Wasti</option> <option value="Ms. Farah Jabeen">Ms. Farah Jabeen</option> </select> <br /> </div> </td></tr><tr><td> <div id="coursediv"> <div align="left"><strong>Course Number</strong>: <select name="course" id="course"> <option>Select courses</option> </select> </div> </div> </td></tr><tr><td> <div align="left"><strong>Department</strong> : <select name="dept" onChange="getDegree(this.value);getDegree(document.fm.dept.selectedIndex);"> <option value="">Select Department</option> <option value="Biochemistry">Biochemistry</option> <option value="Botany">Botany</option> <option value="Business Administration">Business Administration</option> <option value="Chemistry">Chemistry</option> <option value="Commerce">Commerce</option> <option value="Computer Science & IT">Computer Science & IT</option> </select> <br /> </div></td></tr><tr><td> <div align="left"><strong>Degree</strong> : <select name="degree" onChange="getSeat(this.value,this.value,this.value);getSeat(document.fm.degree.selectedIndex,document.fm.batch.selectedIndex,document.fm.semester.selectedIndex);"> <option value="">Select degree</option> <option value="BS(Hons) Biochemistry">BS(Hons) Biochemistry</option> <option value="Biochemistry">Biochemistry</option> <option value="BS(Hons) Botany">BS(Hons) Botany</option> <option value="MSc. Botany">MSc. Botany</option> <option value="BBA(Honors)">BBA(Honors)</option> <option value="MBA">MBA</option> <option value="BS(Hons) Chemistry">BS(Hons) Chemistry</option> <option value="MSc. Chemistry">MSc. Chemistry</option> <option value="B.Com (Honors)">B.Com (Honors)</option> <option value="M.Com">M.Com</option> <option value="B.S (Computer Science)">B.S (Computer Science)</option> <option value="B.S (Information Technology)">B.S (Information Technology)</option> <option value="B.S (Electronics)">B.S (Electronics)</option> <option value="BCS">BCS</option> <option value="MS (Software Engineering)">MS (Software Engineering)</option> </select> <br /> </div></td></tr><tr><td> <div align="left"><strong>Batch</strong> : <select name="batch" onChange="getSeat(this.value,this.value,this.value);getSeat(document.fm.degree.selectedIndex,document.fm.batch.selectedIndex,document.fm.semester.selectedIndex);"> <option value="">Select Batch</option> <option value="2008">2008</option> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> </select> <br /> </div></td></tr><tr><td> <div align="left"><strong>Semester</strong> : <select name="semester" onChange="getSeat(this.value,this.value,this.value);getSeat(document.fm.degree.selectedIndex,document.fm.batch.selectedIndex,document.fm.semester.selectedIndex);"> <option value="">Select Semester</option> <option value="first">first</option> <option value="second">second</option> <option value="third">third</option> <option value="fourth">fourth</option> <option value="fifth">fifth</option> <option value="six">six</option> <option value="seventh">seventh</option> <option value="eighth">eighth</option> </select> <br /> </div></td></tr> </table> <p> </p> <table width="614" border="3" > <tr> <td><div id="seatdiv"> <div align="left"><strong>Seat Numbers</strong> <select name="seat" id="seat"> <option>Select Seat Numbers</option> </select> </div> </div></td> <td><strong>Mid</strong><br/><input name="mid" type="text" id="mid"/ ></td> <td><strong>Lab</strong><br/><input name="lab" type="text" id="lab"/ ></td> <td><strong>Terminal</strong><br/><input name="terminal" type="text" id="terminal"/ ></td> </tr> <tr> <td height="26" colspan="4"><input type="submit" name="Submit" value="Submit" onClick="getCourse(str); getSeat(str,cat,par)"></td> </tr> </table> <p> </p> </form> <p> </p> </body> </html> <?php if (!empty($_GET['seat'])) { $a=$_GET['mid']; $b=$_GET['lab']; $c=$_GET['terminal']; $total=$a+$b+$c; $d; if($total<50) { $d="fail"; } else { $d="pass"; } $per=($total)*100/100; if($per>=90) { $grade="A+"; $gp=4.0; } elseif($per>=85 && $per<=89) { $grade="A"; $gp=4.0; } elseif($per>=80 && $per<=84) { $grade="A-"; $gp=3.8; } elseif($per>=75 && $per<=79) { $grade="B+"; $gp=3.4; } elseif($per>=71 && $per<=74) { $grade="B"; $gp=3.0; } elseif($per>=68 && $per<=70) { $grade="B-"; $gp=2.8; } elseif($per>=64 && $per<=67) { $grade="C+"; $gp=2.4; } elseif($per>=61 && $per<=63) { $grade="C"; $gp=2.0; } elseif($per>=57 && $per<=60) { $grade="C-"; $gp=1.8; } elseif($per>=53 && $per<=56) { $grade="D+"; $gp=1.4; } elseif($per>=50 && $per<=52) { $grade="D"; $gp=1.0; } else { $grade="F"; $gp=0.0; } //$per=($*100)/100; if (!empty($_GET['teacher'])) { $insert="insert into enter_marks_teacher (Full_Name,Course_Number,Dept_Name,Degree,Batch,Semester,Seat_Number,Mid,Lab,Terminal,Total,Remarks,Percentage,Grade,CGPR) values('$_GET[teacher]','$_GET[course]','$_GET[dept]','$_GET[degree]','$_GET[batch]','$_GET[semester]','$_GET[seat]','$_GET[mid]','$_GET[lab]','$_GET[terminal]','$total','$d','$per','$grade','$gp')"; include_once("connect.php"); if(!mysql_query($insert)) { die('error in insert query'); } else { echo("1 Record added"); } } } ?>
findseatno.php
<head> <link href="mystyle.css" rel="stylesheet" type="text/css"> </head> <?php $name=$_GET["batch"]; $name2=$_GET["semester"]; $name3=$_GET["degree"]; $link = mysql_connect("localhost","root",""); //changet the configuration in required if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db("result_system_db",$link); $query="select Seat_Number from student_enroll where Batch_Id=$name and Semester_Id=$name2 and Degree_Id=$name3"; $result=mysql_query($query); echo "<b> Seat Numbers</b>"; echo "<select name='seat'> <option>Select seat numbers</option>"; while($row=mysql_fetch_array($result)) { echo "<option value>".$row['Seat_Number']."</option>"; } echo "</select>"; mysql_close($link); ?>
entermarks.js
function getCourse(str) { if (str=="") { document.getElementById("coursediv").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("coursediv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","findcourse.php?teacher="+str,true); xmlhttp.send("course=" + document.getElementById("course").value); } function getSeat(str,cat,par) { if (str=="") { document.getElementById("seatdiv").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("seatdiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","findseatno.php?degree="+str+"&batch="+cat+"&semester="+par,true); xmlhttp.send("seat=" + document.getElementById("seat").value); }
this code insert and search successfully but when i m using text field in seat numbers firstly come error then second it is not submit may be array using so how i submit multiple values.plz solve my problem. in mysql???
please paste Following details also.. DB, Table and its contain Record.