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 Generation from the Database

In addition to wide range of useful features CodeThatEditor allows you to generate editor script from the database.

At the example 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 database editor generation.

First of all we create table - editor_data with data for editor

Table structure and data are listed below:

CREATE TABLE editor_data
(
	id INT AUTO_INCREMENT NOT NULL,
	note TEXT NOT NULL,
	PRIMARY KEY (id)
);
INSERT INTO editor_data VALUES (1,
	'<h1 align=center>My test</h1><font color="#ff0000" face="Arial"><b><i>
	<u>Colored text</u></i></b></font><font size=1>and</font> <font size=1>text</font>
	<font size=3>with</font> <font size=4>different</font> <font size=5>size</font>
	<font size=6>of</font> <font size=7>fonts</font><br><pre>Formatted text</pre>'
); 

Of course, when you create your real CodeThatEditor script, tables will contain more fields and data.

Next step - we create .php script. Result of this script implementation may be script file or separated content file.

function create_definition($id) {
	global $db;
	$definition = "";
	$result = mysql_query("select * from editor_data where id=$id");
	if ($rs = mysql_fetch_array($result)) {
		$definition = "text : '" . str_replace("\n", "<br>", $rs["note"]) . "'";
	}
	else {
		$definition = "text : ''";
	};
	$definition = "var editorDef={" . $definition . ", style : {width : 400, height : 200," .
	              "defaultClass: 'defaultcss'}}";
	return $definition;
};
if (empty($id)) $id = 1; 

And finally we complete a web page for editor script:

<html>
<head>
<title>Editor Test</title>
<script language="javascript" src="/codethatsdk.js"></script>
<script language="javascript" src="codethateditorpro.js"></script>
<script language="javascript1.2">
<!--
<?php create_definition($id); ?>
//-->
</script> 
<style>
.defaultcss{background-color:"#ffffff",border-color:"#efefe0", border-style:"inset", border-width:2}
</style>
</head>
<body>
  
<script language="javascript1.2">
<!--
var CodeThatEditor = new CEditor("Editor", editorDef);
CodeThatEditor.create(); 	// work with table
//-->
</script>  
  
<form>
	Note # <input type=text name=id value="<?php
		print($id); 
	?>">
	<input type=submit value="Read note">
</form>
</body>
</html>

Example - Editor Generation from the Database

You can see an example and complete code here - Editor Generation from the Database Example [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.