javascript editor java script text editor html wysiwyg editor dhtml tex editor editing made easy wysiwyg text editor web page memo field text editor

PRODUCTS

JavaScript Projects

PHP Projects

Javascript Tools

Website Templates

SUPPORT

Standard vs PRO

FAQ

Forum

Contacts

Site Map

CODETHAT

Sales & Prices

Downloads

Users Testimonials

Affiliate registration

Our Customers

STUDIO   GRID   TABLE   MENU   TREE   XPBAR   HINT   EDITOR   TAB   FORM   CALENDAR   SCROLLER   SHOPPINGCART   TREEPHP   PACKER

User Manual

Introduction    Configure editor look    Configure editor pallete

Data from the database    Data Saving    E-mail sending

Using icons    Editor Reference    Standard vs PRO

123Guide

Examples

Download

Order PRO Now

Themes

CODETHATEDITOR MANUAL

Editor Data Saving

With CodeThatEditor you can store your data on the web server by store data into database

At the examples below we use MySQL as database platform and PHP as web-script language.

But you can choose your own favorite database platform and web-script language.

Here we just try to show basic principles for CodeThatEditor data storing.

Save Data from the Editor at the Database

We will use the same table editor_data that we use in example Editor Generation from the Database

Table structure is listed below:

CREATE TABLE editor_data
(
	id INT AUTO_INCREMENT NOT NULL,
	note TEXT NOT NULL,
	PRIMARY KEY (id)
); 

Then we create .js file to describe CodeThatEditor.

<script language="javascript1.2">
<!--
var editor = new CEditor('sample', editorDef);
editor.create(); 
//-->
</script>

Next step - we create .php script. It contains:

CodeThatEditor initialization part

Form for data export and saving

PHP-functions for DB storing

Here is an example code for form. Defenitely you can create another form.

Export button action is processed by CodeThatEditor script.

<FORM name=exportForm method=post>
<input type=hidden name=data value="">
Note # <input type=text name=id value="<?php print($id); ?>">
<INPUT type=submit value="Save on server DB" name=dbsave
	onClick="exportForm.data.value=CodeThatEditors['sample'].getText()">
</FORM>

Note: editor and CodeThatEditors['sample'] are the same object CodeThatEditor, this is alternative way to refer to the Object Editor

There is a php code for saving data at the database:

<php
if (!empty($data)) {
	//here some data to save
	if (!empty($id)) {
		$query = "update editor_data set note='$data' where id=$id"; //modify exist record
	}
	else {
		$query = "insert into editor_data (note) values ('$data')"; //add new one
	};
	//save data
	mysql_query($query);
	$error = mysql_error();
	if ($error) print($error);
	else print("<p>All CodeThatEditor data have been successfully stored at the server database!");
};
//read data
if (empty($id)) {
	$query = "select max(id) from editor_data";
	$result = mysql_query($query);
	if ($rs = mysql_fetch_row($result)) $id = $rs[0];
	else $id = 0;
};
$query = "select * from editor_data where id=$id";
$result = mysql_query($query);
if ($rs = mysql_fetch_array($result))
$text = str_replace("\r", "", str_replace("\n", "'\n+'", str_replace("'", "&#39;", $rs["note"])));
else $text = ""; 
?>
<html>
 <head>
  <title>Editor Test</title>
  <link href="/common_codethat.css" rel="stylesheet" type="text/css">	
  <script language="javascript1.2">
<!--
codethatsdk.js">
//-->
</script>	
  <script language="javascript" src="codethateditorpro.js"></script>       
  <style>
   .defaultcss{background-color:"#ffffff",border-color:"#efefe0", border-style:"inset", border-width:2}
  </style>
 </head>
 <body>
  
<script language="javascript1.2">
<!--
var editorDef = {
	text : '<?php print($text); ?>',
	style : {
		width : 400,
		height : 200,
		defaultClass : {
			backgroundcolor : "#ffffff", bordercolor : "#efefe0",
			borderstyle : "inset", borderwidth : 2
		}
	}
};
var editor = new CEditor('sample', editorDef);
editor.create(); 
//-->
</script>

Example - Data saving at the database

You can see an example and complete code here - Data saving at the database [popup]

Read more about CodeThatEditor >>

[ Home ]  [ Forum ]  [ Contacts ]  [ Site Map ]  [ News ]  [ Links ]  [ Sales & Prices ]  [ Downloads ]

[ Go Top ]

© CodeThat.com, 2003-2008
Design by XTLabs, Inc.