This is my form-
Code: Select all
<html>
<head>
<script type="text/javascript" >
var xmlhttp = false;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
function getCusName()
{
xmlhttp.open("GET","customerdb.php",true);
xmlhttp.onreadystatechange = updateName;
xmlhttp.send(null);
}
function updateName()
{
if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
response=xmlhttp.responseText;
document.getElementById("showCustomer").innerHTML = response;
}
}
function getEditForm()
{
var val=document.getElementById("linkname").innerHTML;
}
</script>
</head>
<body onload="getCusName()">
<div id="showCustomer">Content for id "showCustomer" Goes Here</div>
</body>
</html>Code: Select all
<?php
$dbhost="localhost";
$dbuser="root";
$dbpass="admin";
$dbname="classicmodels";
//Connect to MySQL Server
$con=mysql_connect($dbhost,$dbuser,$dbpass,$dbname);
//Select Database
mysql_select_db($dbname,$con) or die( mysql_error());
//build query
$query = "SELECT customerName FROM customers LIMIT 0,10";
$qry_result = mysql_query($query) or die(mysql_error());
//Build Result String
$display_string = "<table>";
$display_string .= "<tr>";
$display_string .= "<th><b>Customer Names</b></th>";
$display_string .= "</tr>";
// Insert a new row in the table for each person returned
while($row = mysql_fetch_array($qry_result)){
$name=$row[customerName];
$display_string .= "<tr>";
$display_string .= "<td><a id='linkname' href='javascript:getEditForm()'> $name </a></td>";
$display_string .= "</tr>";
}
$display_string .= "</table>";
echo $display_string;
?>