我正在使用javascript制作带有内联编辑的html表格,当表格td使用内联编辑编辑时我想将编辑后的值保存在数据库中我不知道如何将编辑后的值传递到数据库并保存,请任何人指导我如何做到这一点谢谢。
我的java脚本
<script type='text/javascript'>
window.onload=function(){
$("table td").click( function( e ){
if ( $(this).find('input').length ) {
return ;
}
var input = $("<input type='text' size='5' />")
.val( $(this).text() );
$(this).empty().append( input );
$(this).find('input')
.focus()
.blur( function( e ){
$(this).parent('td').text(
$(this).val()
);
});
});
</script>
html
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> edit</title>
</head>
<body>
<?php
$dbHost = 'localhost'; // usually localhost
$dbUsername = 'fms';
$dbPassword = 'xxxxx';
$dbDatabase = 'fms';
$db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die ("Unable to connect to Database Server.");
mysql_select_db ($dbDatabase, $db) or die ("Could not select database.");
$sql = mysql_query("SELECT * FROM supplierprice");
echo "<table border='1'>
<tr>
<th>Region</th>
<th>Country</th>
<th>Network Name</th>
<th>Mcc</th>
<th>Mnc</th>
<th>Mnp</th>
</tr>";
while($row=mysql_fetch_array($sql))
{
echo "<tr>";
echo "<td>" . $row['region'] . "</td>";
echo "<td>" . $row['country'] . "</td>";
echo "<td>" . $row['networkname'] . "</td>";
echo "<td>" . $row['mcc'] . "</td>";
echo "<td>" . $row['mnc'] . "</td>";
echo "<td>" . $row['mnp'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>