hello world,
myself kishan kumar, iam new to web developing...my task is interrelated to edit,save & cancel....which is similar to edit button in shine.com...Iam doing in php language.the work is when user clicks on edit button he must be able to edit and after on editing he can save it i.e updation in database.....(when user clicks on edit button, save and cancel buttons should come and moreover the save and cancel buttons should occur in same page.......thanks..my php code is
<?php
mysql_connect("localhost","root","")or die (mysql_error ());
mysql_select_db("edit")or die (mysql_error ());
$eduser=$_POST['user'];
$edpassword=$_POST['password'];
$sql="SELECT * FROM members WHERE uname='".$eduser."' and password='".$edpassword."'";
$result=mysql_query($sql);
while($info=mysql_fetch_array($result))
{
if($eduser=$edpassword)
{
?>
<p>
<table width="45%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
<form id="fn">
<div>
<input class="edit" type="button" value="Edit" />
<input class="save" type="button" value="Save" />
<input class="cancel" type="button" value="Cancel" />
</div>
<tr>
<td><input type="text" value="<?php echo $info['fname'];?>" /></td>
<?php echo "<p></p>"; ?>
<td><input type="text" value="<?php echo $info['lname'];?>" /></td>
<?php echo "<p></p>"; ?>
<td><input type="text" value="<?php echo $info['email'];?>" /></td>
<?php echo "<p></p>"; ?>
</form>
</tr>
<?php
}
else
{
echo "somewhere mistake";
}
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type='text/css'>
.save, .cancel {
display:none;
}
</style>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$('#fn').hide();
$('.edit').click(function() {
$(this).hide();
$(this).siblings('.save, .cancel').show();
$('#fn').show();
});
$('.cancel').click(function() {
$(this).siblings('.edit').show();
$(this).siblings('.save').hide();
$(this).hide();
$('#fn').hide();
});
$('.save').click(function() {
$(this).siblings('.edit').show();
$(this).siblings('.cancel').hide();
$(this).hide();
$('#fn').hide();
});
});//]]>
</script>
</head>
<body>
</body>
</html>
and my database is -- phpMyAdmin SQL Dump
-- version 3.4.5
-- Host: localhost
-- Generation Time: May 21, 2014 at 11:04 AM
-- Server version: 5.5.16
-- PHP Version: 5.3.8
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /;
/!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /;
/!40101 SET NAMES utf8 */;
--
edit
-- --------------------------------------------------------
--
members
CREATE TABLE IF NOT EXISTS members
(id
int(11) NOT NULL AUTO_INCREMENT,fname
varchar(100) NOT NULL,lname
varchar(100) NOT NULL,email
varchar(50) NOT NULL,uname
varchar(255) NOT NULL,password
varchar(20) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
members
INSERT INTO members
(id
, fname
, lname
, email
, uname
, password
) VALUES
(1, '1', '1', '1', 'kishan', 'kumar'),
(2, 'kishan', 'kumar', 'kishankumar1220@yaho.com', 'madhava', 'nakrekal'),
(3, 'ravitgh6yuj5', 'uyttyyyytyt5ju5475', 'kiran@hotmail.com', 'sripriya', 'nalg');
/!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS /;
/!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;