クリックしたときにセルの値を編集する以下のコードがありますが、ユーザーが保存ボタンをクリックしたときに新しい値をデータベースに保存したい..助けてください
<?php include"connect.php"; ?>
<html>
<head>
<title>Edit time records</title>
<style>
table{ text-align:justified;}
a {text-decoration:none;
color:black;
}
.replace {display:none;}
</style>
<link rel="stylesheet" type="text/css" href="css/allRecordsStyle.css">
<script type="text/javascript">
/*<![CDATA[*/
function INPUT(id){
var obj=document.getElementById(id),tds=obj.getElementsByTagName('SPAN'),z0=0,ip,html;
for (;z0<tds.length;z0++){
tds[z0].onmouseup=function(){ AddInput(this); }
}
}
function AddInput(td){
var ip=zxcAddField('INPUT','text','');
ip.value=td.innerHTML;
ip.ondblclick = function () { removeInput(ip); };
td.innerHTML='';
td.appendChild(ip);
td.onmouseup=null;
}
function removeInput(input) {
var val = input.value;
var td = input.parentNode;
td.removeChild(td.lastChild);
td.innerHTML = val;
td.onmouseup = function () { AddInput(td); };
}
function zxcAddField(nn,type,nme){
var obj;
try {
obj=document.createElement('<'+nn+' name="'+(nme||'')+'" '+(type?'type="'+type+'" ':'')+' >');
}
catch(error){
obj=document.createElement(nn);
if (type){
obj.type=type;
}
obj.name=nme||'';
}
return obj;
}
/*]]>*/
</script>
<script type="text/javascript">
/*<![CDATA[*/
function Init(){
INPUT('tst');
}
if (window.addEventListener){
window.addEventListener('load',Init, false);
}
else if (window.attachEvent){
window.attachEvent('onload',Init);
}
/*]]>*/
</script>
</head>
<body>
<a href="admin.php">back</a>
<?php
echo "<table border=1 id='tst' class='tab'>";
echo "<tr><th class='data' rowspan='2' ><strong>EMPLOYEE</strong></th>";
echo "<th class='data' rowspan='2'>DATE</th>
<th colspan='2'>AM</th>
<th colspan='2'>PM</th>
<th colspan='2'>OVERTIME</th></tr>";
echo "<tr>
<th>Arrival</th>
<th>Departure</th>
<th>Arrival</th>
<th>Departure</th>
<th>In</th>
<th>Out</th>
</tr>";
$query="SELECT
employee_detail.employee_code,
employee_detail.lname,
employee_detail.fname,
employee_detail.mname,
employee_record.date,
employee_record.am_in,
employee_record.am_out,
employee_record.pm_in,
employee_record.pm_out,
employee_record.over_in,
employee_record.over_out
FROM employee_detail INNER JOIN employee_record ON employee_record.employee_code=employee_detail.employee_code ORDER BY id DESC ";
$result=mysql_query($query);
$affected=mysql_affected_rows();
while($affected>=1&&$row=mysql_fetch_array($result))
{
echo '<tr><td>';
echo $row['lname'].", ";
echo $row['fname']." ";
echo $row['mname']."</td>";
echo '<td>'.$row['date'].'</td>';
echo '<td><span name="am_in">'.$row['am_in'].'</span></td>';
echo '<td><span name="am_out">'.$row['am_out'].'</span></td>';
echo '<td><span name="pm_in">'.$row['pm_in'].'</span></td>';
echo '<td><span name="pm_out">'.$row['pm_out'].'</span></td>';
echo '<td><span name="over_in">'.$row['over_in'].'</span></td>';
echo '<td><span name="over_out">'.$row['over_out'].'</span></td></tr>';
$affected--;
}?>
<input id="save" type="submit" value="Save Changes" onclick=""/>
</body>
</html>