?
Solved

Simple editable html table

Posted on 2011-03-08
4
Medium Priority
?
432 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

801 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