Create employee table as follows
EMP(eno, ename, designation, salary). Write Ajax program to select the employees name and print the selected employee’s details.setb1.html
<html>
<head>
<script type="text/javascript">
function display()
{
n=f1.name1.value;
if(window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","setb11.php?name1="+n,true);
xmlhttp.send();
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById('res').innerHTML = xmlhttp.responseText;
}
}
}
</script>
<body>
<form name="f1">
ENTER EMPLOYEE NAME
<input type="text" name="name1"/><br>
<input type="button" value="submit" onclick="display()"/>
</form>
<div id='res'></div>
</body>
</html>
setb1.php
<?php
$a=$_REQUEST['name1'];
$con=pg_connect("host=192.168.100.10 port=5432 dbname=tybcs4 user=tybcs4") or die("connection not establish");
$result=pg_query("select * from employee1 where e_name='$a'");
echo "<table border=1>";
echo "<tr>";
echo "<th>Number</th>";
echo "<th>Name</th>";
echo "<th>Address</th>";
echo "<th>Salary</th>";
echo "</tr>";
while($row=pg_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row['e_no']."</td>";
echo "<td>".$row['e_name']."</td>";
echo "<td>".$row['e_add']."</td>";
echo "<td>".$row['e_salary']."</td>";
}
echo "</tr>";
echo "</table>";
?>
0 Comments
If anyone has Doubts or suggestions please let me know