Solved

Simple editable html table

Posted on 2011-03-08
4
414 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

828 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