Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa PHP How can i search and insert within a query
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


jabeen sarwar
How can i search and insert within a query
1 Answer(s)      3 years and a month ago
Posted in : PHP


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


Advertisement
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
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 insert image into struts text field
Can i insert image into struts text field  please tell me can i insert image into text field
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
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 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
single query to insert the data
single query to insert the data  How to insert data for all HTML fields in single MYSQL query
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
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
Hibernate insert Query
will demonstrate you how to use HQL insert query in your program. To explain this query I...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
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
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 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
need search query - WebSevices
need search query  I have a field in database as DOB. But I want to search recrods as per "fromage" to "toage". I dont know how to compare the ages...; create table stu(name varchar(10), dob date); insert into stu values('komal
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 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 can i make monthly register ?
how can i make monthly register ?  how can i make monthly register ? iam using jdeveloper
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
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
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 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. Thanks
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 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 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 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
 

 

 

DMCA.com