Interspire Product Knowledge Base

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Remove from favorites Remove from favorites

Remove Highlighting Remove Highlighting

Edit this Article

Export to PDF

User Opinions (6 votes)

33% thumbs up 66% thumbs down

How would you rate this answer?

Thank you for rating this answer.

How can I load a value from a MySQL database, edit it and then save it again?

This is easy to accomplish, so let's see an example. Firstly, create a database with one table:

create database myDatabase;
use myDatabase;

create table myTable
keyId int auto_increment,
content text,
primary key(keyId),
unique id(keyId)

Next, create a test record:

insert into myTable values(0, '<b>this is some text!</b>');

Now, the PHP code (you should change the database details to match your MySQL setup):


$myDE = new DevEdit;

// Connect to the database
$dbServer = "localhost";
$dbUser = "admin";
$dbPass = "password";
$dbName = "myDatabase";

$c = mysql_connect($dbServer, $dbUser, $dbPass) or die("Couldn't connect to database");
$d = mysql_select_db($dbName) or die("Couldn't select database");

if(@$_POST["save"] == "true")
$content = $myDE->GetValue(true);
$result = @mysql_query("update myTable set content = '$content' where keyId = 1");

echo "Content.php saved!<br><br><a href='test.php'>Continue</a>";
$result = mysql_query("select content from myTable where keyId = 1");

if($row = mysql_fetch_array($result))
$data = $row["content"];
$data = "";

<form action="test.php" method="post">
<input type="hidden" name="save" value="true">
<?php $myDE->ShowControl(400, 300, "my_image_dir"); ?>

<input type="submit" value="Save">

Note: This is an example. You may have to change parts of the code above to get it to work.

Related Articles

No related articles were found.


No attachments were found.

Powered by Interspire Knowledge Manager - World's #1 Best Selling FAQ and Knowledge Base Software