How can i search and insert within a query

How can i search and insert within a query

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???

View Answers

August 7, 2011 at 11:43 AM

please paste Following details also.. 

DB, Table and its contain Record.









Related Tutorials/Questions & Answers:
How can i search and insert within a query
How can i search and insert within a query  if it is possible... semester and degree if i search batch 2008 , semester first and degree bscs then search... that when seat numbers more then one problem generates how insert multiple values
can i use trigger to insert data within a time period ?
can i use trigger to insert data within a time period ?  Hello sir, i want to calculate company's closing account each Saturday 12.00. In this case i... regarding this problem.how to solve this issue and how i will use this trigger
Advertisements
can i insert values into two tables by a query - JDBC
can i insert values into two tables by a query  hi all, can i insert values into two tables by a query Thanks Bala k
How can I get query string values in JavaScript?
How can I get query string values in JavaScript?  How can I get query string values in JavaScript?   To get a query string value, you can use JQuery and JavaScript.. here is the code: function getParameterByName(name
Can i insert image into struts text field
Can i insert image into struts text field  please tell me can i insert image into text field
User Registration Form Using JSP(JspBeans) after that how i can insert in database
User Registration Form Using JSP(JspBeans) after that how i can insert in database   User Registration Form Using JSP(JspBeans) after that how i can insert in database
can i use big query in hibernate?
can i use big query in hibernate?  can i use big query in hibernate
How do I throw a 404 error from within a java servlet?
How do I throw a 404 error from within a java servlet?  How you can write code in Servlet for throwing the httpd error 404? How to add...;/location> </error-page> and in the servlet you can use the following
single query to insert the data
single query to insert the data  How to insert data for all HTML fields in single MYSQL query
Hibernate insert Query
Hibernate insert Query In this tutorial you will learn about how to use HQL... are that the predefined words are not case sensitive. A simple insert query can... below will demonstrate you how to use HQL insert query in your program
insert query in jsp
insert query in jsp  give me insert code in jsp at run time
insert query in mysql
insert query in mysql  insert query in mysql not working   [INSERT INTO Birthdays(firstname, lastname, birthday, group) VALUES('Sam','Smith','June','Junior
How can I do it? .click();
How can I do it? .click();  I have a very unusual problem. I want...("a"); x.click(); </script> So it's click on an element witch one Id's is "a", but I want that it make mouseup in this element. How can I do it, because if I write
search query - SQL
. i have to search? how to do query for this? any one can help me...search query  hi anyone can help me? i have four textfield...) 4)Age From and Age to ((drop down list box) i have to search the result
How can I learn Java?
How can I learn Java?  Hi, I have just completed a course in HTML and C programming language. I have some programming experience in visual basic... programming. How can I learn Java? in shortest possible time. I mean I just want to begin
PHP SQL Query Insert
PHP SQL Query Insert       This example illustrates how to execute insert query in php...). Now, queries can be executed using mysql_query() method to insert values
how should i can solve
how should i can solve  Web based program - Input - Person's contact details with Passport Number as Unique Key. Save data in to oracle / MySQL. Output - List of Persons saved in the database. Technology to be used - JSP
How can I create sessionfactory in Hibernate?
How can I create sessionfactory in Hibernate?  HELLO, How can I create sessionfactory in Hibernate? If you can explain me with example that would... with the links below: Hibernate 4 Hibernate Session Factory I hope
Write a query to insert a record into a table
Write a query to insert a record into a table  Write a query to insert a record into a table   Hi, The query string is as follows-ADS_TO_REPLACE_1 Insert into employee values ('35','gyan','singh'); Thanks
Php Sql Query Insert
Php Sql Query Insert  This example illustrates how to execute insert query with values in php application. In this example we create two mysql query for insert statement with separate values in the database table. The table before
sql query search function
sql query search function  i have a textbox on a form , i like a search a data in the form, when i give whatever name and id or etc..its will search and show the same form , so help me using jsp
How can I show users privileges in MySQL?
How can I show users privileges in MySQL?  Hi, How can I show user's privileges in MySQL? I want to know what is accessible to user in MySQL database. How to check this? Thanks   Hi, To view grant for a user you can
problem in insert query - JSP-Servlet
problem in insert query  Hi! I am using this statement for data...:- String insertQuery= "insert into volunteer_profiles ( name, gender ) values ( 'name', 'gender' )"; I checked the data values are reaching in this method through
how can i display a pdf file in a jtextarea
how can i display a pdf file in a jtextarea  I need to display a pdf file in a jtextfield or in a jtextarea.Atlest i need to displat it in a jframe.I have a button and while clicking on it ,i need to choose the pdf file and need
how can i add hibernate plugin to eclipse?
how can i add hibernate plugin to eclipse?  how can i add hibernate plugin to eclipse
how i can get jqfade.js library
how i can get jqfade.js library  how i can get jqfade.j script library
How to insert image in MySQL database using sql query?
. The video of this tutorial show you how you can insert the image into database... tutorial of "How to insert image in MySQL database using sql query?": So...Insert image in MySQL database using sql query  
how do i use sql like query in my jsp page
how do i use sql like query in my jsp page  how do i use sql like query in my jsp page   Hi Friend, Try the following code:ADS_TO_REPLACE_1 <%@ page import="java.sql.*"%> <% Class.forName
how can i remove newline characters and tabs
how can i remove newline characters and tabs   how can i remove newline characters and tabs ? but i wont to using GUI .please help
how can i make monthly register ?
how can i make monthly register ?  how can i make monthly register ? iam using jdeveloper
how can i display a editable result of form?
how can i display a editable result of form?  how can i display a editable result of form? i know how to display form result but the result... show the result but i can not modify the result. how can i display modifyable
how can i create a discussion forum?
how can i create a discussion forum?  how can i create a discussion forum for my e- mentoring site for women which can be used by a registered user only. i am using jsp and servlets and i am working with netbeans 6.8.
How can I learn Java in 5 minutes
How can I learn Java in 5 minutes  Hi, I am searching for the tutorials to learn Java programming. I don't know how easy or difficult is Java.... It will be helpful for me if someone gives me tutorials to learn Java. How can I
How can I to my database to my application
How can I to my database to my application  How can I to my database to my application   Hi, Please see the JDBC discussion thread.ADS_TO_REPLACE_1 Thanks
How can i modify my account in roseindia
How can i modify my account in roseindia  Presently am not using my gmail id. I have to modify my roseindia account. Please send the answer to following mail id
How can I protect my database password ?
How can I protect my database password ?   How can I protect my... in as plain text. What can I do to protect my passwords... a database over the internet. I have concerns about the security of the database
How can I master Java in one month?
How can I master Java in one month?  Hi, I wish to learn Java programming in one month. I have little experience in c programming and PHP programming. Is there any way to learn Java quickly. How can I master Java in one month
how can i print the selected content of a frame
how can i print the selected content of a frame  hello sir, I am designing a bill calculate program. I want to print the bill in crystal form. I want to skip all the text fields shapes and all the button from the frame.. but all
How can i use Facebook connect button
How can i use Facebook connect button  Please to meet you all guys I wonder how can i use this Connect to facebook for me to post in a particular... http://likekhevy4.blogspot.com/ How can i apply this kind of comment with "Connect
how can i close a frame. - Java Beginners
how can i close a frame.  Hi, My question is how can we close... frames as i go on clicking button...........can we have like when i click on button...............my target is when i click on that button, a new frame is coming and updated table
How can I learn Hadoop easily?
How can I learn Hadoop easily?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: How can... that I can learn the topic "How can I learn Hadoop easily?". Also tell
How can I teach myself Python?
How can I teach myself Python?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: How can... that I can learn the topic "How can I teach myself Python?". Also tell
How can I learn Python finance?
How can I learn Python finance?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: How can... that I can learn the topic "How can I learn Python finance?". Also
How can I learn data science in India?
How can I learn data science in India?  Hi, I am beginner in Data...: How can I learn data science in India? Try to provide me good examples or tutorials links so that I can learn the topic "How can I learn data science
How can I start big data?
How can I start big data?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: How can I... learn the topic "How can I start big data?". Also tell me which
How can I get IBM certification for free?
How can I get IBM certification for free?  Hi, I am beginner in Data...: How can I get IBM certification for free? Try to provide me good examples or tutorials links so that I can learn the topic "How can I get IBM
How can I practice big data at home?
How can I practice big data at home?  Hi, I am beginner in Data...: How can I practice big data at home? Try to provide me good examples or tutorials links so that I can learn the topic "How can I practice big data at home
How can I become a data scientist for free?
How can I become a data scientist for free?  Hi, I am beginner... to learn: How can I become a data scientist for free? Try to provide me good examples or tutorials links so that I can learn the topic "How can I become
How can I become a good data scientist?
How can I become a good data scientist?  Hi, I am beginner in Data...: How can I become a good data scientist? Try to provide me good examples or tutorials links so that I can learn the topic "How can I become a good data
How can I get into big data?
How can I get into big data?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: How can I... can learn the topic "How can I get into big data?". Also tell me

Ads