Hi All,
I believe it is very simple but some how I get stuck here. my problem is I have 2 editor in one page where one retrieve data from mysql $content1 and other editor retrieve data from $content2. But when I update the data to mysql, it seem that the value only update the of $content2 but not $content1, end up in mysql table, both fields of $content1 & 2 storing the same value.....how and why it happen????
here is my code:
//edit from the page
$Result = mysql_db_query ($DBName, $Query, $Link) or die("select: ".mysql_error());
While ($Row = mysql_fetch_array ($Result)){
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = '../aoe2007/texteditor/' ;
$oFCKeditor->Value = $Row[content];
$oFCKeditor->Width = '780' ;
$oFCKeditor->Height = '540' ;
$oFCKeditor->Create() ;
$oFCKeditor = new FCKeditor('FCKeditor2') ;
$oFCKeditor->BasePath = '../aoe2007/texteditor/' ;
$oFCKeditor->Value = $Row[title1];
$oFCKeditor->Width = '780' ;
$oFCKeditor->Height = '540' ;
$oFCKeditor->Create() ;
}
}
//update data to mysql:
<?php if ( isset( $_POST ) ) $postArray = &$_POST ; // 4.1.0 or later, use $_POST else $postArray = &$HTTP_POST_VARS ; // prior to 4.1.0, use HTTP_POST_VARS foreach ( $postArray as $sForm => $value ) { $postedValue1 = stripslashes( $value ) ; $postedValue2 = stripslashes( $value ) ; $Query = "UPDATE invite_emailsin SET title1='$postedValue1', content='$postedValue2' WHERE id='1'"; $result = mysql_db_query ($DBName, $Query, $Link) or die(mysql_error()); if(!$result) { echo 'database cannot be process!'; } else { echo 'content insert into dasebase!'; ?>
I think it is the $value that I set wrongly or other reasons...so how should I update data to mysql if I have 2 editors but in dealing defferent field? pls help me !!!!
RE: how to store data if you have 2 fckeditor
The problem is in your foreach... basic php...not really a fckeditor problem... a for each is a loop, which ends when your it reached the end of the array. I dont see why yu are using a foreach for your post vars also try using the {} braces right way...but try this:
//update data to mysql:
<?php if ( isset( $_POST ) ) { $postArray = &$_POST ; // 4.1.0 or later, use $_POST } else { $postArray = &$HTTP_POST_VARS ; // prior to 4.1.0, use HTTP_POST_VARS } $Query = "UPDATE invite_emailsin SET title1='".stripslashes($postArray[0])."', content='".stripslashes($postArray[1])."' WHERE id='1'"; $result = mysql_db_query ($DBName, $Query, $Link) or die(mysql_error()); if(!$result) { echo 'database cannot be process!'; } else { echo 'content insert into dasebase!'; } ?>