am trying to make the user update records by clicking on the record
but something wrong and id ont know why it didnt work
it gave me this error when i change the value where web is the origianl valyue and webaaa what i wrote to be edited
update porto set porto_name = 'Webaaa' where porto_ID=''
and here is the code
<head>
<script type="text/javascript">
var contents = '';
function toggle(porto_ID)
{
if (document.getElementById('r_'+porto_ID).style.display == 'none')
{
if (document.forms['form_'+porto_ID].porto_name.value != contents)
{
// If the contents of the box have changed, submit the form.
document.forms['form_'+porto_ID].submit();
}
document.getElementById('w_'+porto_ID).style.display = 'none';
document.getElementById('r_'+porto_ID).style.display = 'inline';
}else
{
document.getElementById('w_'+porto_ID).style.display = 'inline';
document.forms['form_'+porto_ID].porto_name.focus();
contents = document.forms['form_'+porto_ID].porto_name.value;
document.getElementById('r_'+porto_ID).style.display = 'none';
}
}
</script>
</head>
<?php
$conn=mysql_connect("localhost","root","123456");
$db=mysql_select_db("epic");
$Recordset1=mysql_query("select * from porto");
?>
<table >
<tr>
<th>Name</th>
</tr>
<?php do{ ?>
<tr>
<td>
<div id="r_<?php echo $row_Recordset1['porto_ID']; ?>" onclick="toggle('<?php echo $row_Recordset1['porto_ID']; ?>')">
<?php echo $row_Recordset1['porto_name']; ?>
</div>
<div id="w_<?php echo $row_Recordset1['porto_ID']; ?>" style="display: none;">
<form id="form_<?php echo $row_Recordset1['porto_ID']; ?>" method=post
action=<?php echo $_SERVER['PHP_SELF']; ?> >
<input onblur="toggle('<?php echo $row_Recordset1['porto_ID']; ?>')"
type=text
name="porto_name" value='<?php echo $row_Recordset1['porto_name']; ?>' />
</form>
</div>
</td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<?php
if($porto_name){
$query_line = "update porto set porto_name = '". $porto_name ."' where porto_ID='".$porto_ID."'";
$sql = mysql_query($query_line);
if(!$sql) echo mysql_error() . $query_line;
}
i think he didn't recognize the porto_id