•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 401,517 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,368 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 333 | Replies: 1
![]() |
•
•
Join Date: Apr 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
all i want is to make the user able to edit when he clicks on the value and on blur the value get edited
like it works here in the forum ,when i try to edit,it edited on the same page !! and i got this code,it works fine if i changed the update statement to insert
but in updating , it doesnt update anything and when i echoed the statement it gave me that:
[php]
update porto set porto_name = 'Websss' where porto_ID=''
[/php]
and this is the code
[php]
<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;
}
[/php]
like it works here in the forum ,when i try to edit,it edited on the same page !! and i got this code,it works fine if i changed the update statement to insert
but in updating , it doesnt update anything and when i echoed the statement it gave me that:
[php]
update porto set porto_name = 'Websss' where porto_ID=''
[/php]
and this is the code
[php]
<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;
}
[/php]
Last edited by ausgezeichnete : Jan 17th, 2008 at 4:40 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- input to binary (C)
- converting Enum type from int to char (C)
- converting C++ to C (C++)
- Converting lowercase type to uppercase (new programmer) (Java)
- Converting numbers to text equivalent (C#)
- Converting Java to C (Java)
- Bubble sort & File output jibrish errors??? (C)
- Converting Dec to Hex without using IntToHex... (Pascal and Delphi)
- Sorting Video titles using a ID numbers (Java)
- C file input/output 2D arrays. (C)
Other Threads in the PHP Forum
- Previous Thread: How do I upload images to mysql database using php5
- Next Thread: publicly viewable XAMPP htdocs folder


Linear Mode