Solved

Simple editable html table

Posted on 2011-03-08
4
395 Views
Last Modified: 2012-05-11
How can I find a simple, editable html table.

I just need to edit one row at a time and submit the changes to a database.

The simplest possible solution would be appreciated.
0
Comment
Question by:pillmill
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35076007
For example :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script language="javascript">
	$(document).ready(function() {
		$("input", "table").blur(function() {
			if( confirm("apply changes") ) $.post("update.php", { "id":$(this).attr("id"), "val":$(this).val() } );
		});
	});
</script>
</head>
<body>
<table>
<tr><td><input id="1" value="10" /></td></tr>
<tr><td><input id="2" value="25" /></td></tr>
</table>
</body>
</html>

Open in new window


Server side something like :
<?PHP
	include "includes/connect.inc";

	if( isset($_REQUEST["id"]) && isset($_REQUEST["val"]) ) {

		$id = mysql_real_escape_string($_REQUEST["id"]);
		$val = mysql_real_escape_string($_REQUEST["val"]);
		
		$query = "UPDATE myTable SET myField=$val WHERE id=$id";
		$result = mysql_query($query,$connexion);

		if(!$result) {
			echo mysql_errno($connexion) . "\n";
			die("bad query : " . mysql_error());
		}
	}
?>

Open in new window

0
 
LVL 2

Expert Comment

by:cyberhitesh
ID: 35085452
Check out dhtmlxGrid is an Ajax-enabled JavaScript grid control it allows you to show data in table and also provides you functionality to edit and save the data using Ajax call.

URL: http://dhtmlx.com/docs/products/dhtmlxGrid/
0
 

Author Comment

by:pillmill
ID: 35089898
Thanks leakim971:

Is it possible to make this editable by row?

0
 
LVL 82

Expert Comment

by:leakim971
ID: 35089944
this is the case.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now