User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Apr 2007
Posts: 2
Reputation: ausgezeichnete is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ausgezeichnete ausgezeichnete is offline Offline
Newbie Poster

Help Converting from Output to Input !

  #1  
Jan 17th, 2008
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]
Last edited by ausgezeichnete : Jan 17th, 2008 at 4:40 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 251
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 13
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: Converting from Output to Input !

  #2  
Jan 18th, 2008
use ajax
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 2:53 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC