Simple PHP Help required for FCKeditor

Discussion in 'PHP' started by hallianonline, Sep 16, 2014.

  1. #1
    Hello, I am using FCKeditor to inserting news content
    now my problem is after submitting the news sucessfully. I get all other new items on the same page if i need to edit them on clicking the edit button the fckeditor not loads the old content until i change this part from
    $oFCKeditor = new FCKeditor('news_description'); to $oFCKeditor = new FCKeditor('anyother_name');

    but trouble for me is this news_description is the important one
    which repeats multiples times

    here is my code for for submitting the news


      <tr>
      <td align="right">News Detail :&nbsp;</td>
      <td><label>
      
      
             <?php    
               include("FCKeditor/fckeditor.php");    
               $oFCKeditor = new FCKeditor('news_description');
               $oFCKeditor->BasePath = 'FCKeditor/';
               $oFCKeditor->Value = nl2br($htmlData);
               $oFCKeditor->Create();
           ?>
      </label></td>
      
      </tr>
    PHP:



    and this code which creates list items for editing the news and load news items
    <?php
            ///////////////////////////////////////////////////////////////////////////////////////
            include('common/pagingprocess.php');
            ///////////////////////////////////////////////////////////////////////////////////////
            $sql .=  " LIMIT ".$start.",".$limit;
            $i=$i+$start;
            $result = @mysql_query($sql);
            $rec = array();
            while( $row = @mysql_fetch_array($result) )
            {
             $rec[] = $row;
            }
           if(count($rec)>0)
           {
             foreach($rec as $items)
             {
              
         ?>
              <tr>
               <td><?php echo ++$i;?> </td>
               <td><?php echo $items['news_heading'];?> </td>
      <td><?php echo $items['news_description']; ?> </td>
      <td><?php
               $timestamp= strtotime($items['date_added']);
               echo strftime('%d %B %Y %X', $timestamp);
              
               ?> </td>
      <td><?php if($items['news_status'] == 1) echo "Active"; else echo "Inactive"; ?> </td>
      
      <div id="dialog_<?php echo $items['news_id']; ?>" title="<?php echo $items['news_heading'];?>" style="display:none;">
      <p><img src="<?php echo ru_media; ?>news_image/<?php echo $items[news_image] ;?>"  /></p>
      </div>
      <td valign="middle">
                 <img src="<?php echo ru_img;?>viewIcon.gif"  style="cursor:pointer;" title="Edit News" id="logo_<?php echo $items['news_id'];?>" onclick="modelme(<?php echo $items['news_id'];?>)"  />
      
      <img src="<?php echo ru_img;?>edit.gif"  style="cursor:pointer;" title="Edit News" onclick="document.getElementById('<?php echo $items['news_id'];?>').style.display='block'"  />   &nbsp;&nbsp;
      <img src="<?php echo ru_img;?>dlt.gif"  style="cursor:pointer;" title="Delete News" alt="Delete News" onclick="if(confirm('Are sure you want to delete')){window.location='<?php echo ruadmin; ?>process/process_news.php?p=del&id=<?php  echo $items["news_id"];?>&script=news' }"  />
                
         </td>
            </tr>  
      
      
      
      
      <tr>
      
      <td colspan="7" align="right">
      <div id="<?php echo $items["news_id"];?>" style="display:none;">
      
      <form name="form1" enctype="multipart/form-data" action="<?php echo ruadmin; ?>process/process_news.php?p=editnews&id=<?php  echo $items["news_id"];?>&script=news" method="post">
      News Heading: &nbsp;<input type="hidden" name="editnews" id="editnews" value="<?php echo $items['news_id'];?>"/>
      <input type="text" name="edit_news_heading" id="edit_news_heading" size="30" class="text-input" value="<?php echo $items['news_heading'];?>"/><br />
      News Detail: &nbsp;
      
             <?php    
               $templatecontent = html_entity_decode(stripslashes($items['news_description']));                
               include("FCKeditor/fckeditor.php");    
               $oFCKeditor = new FCKeditor('news_description');
               $oFCKeditor->BasePath = 'FCKeditor/';
               $oFCKeditor->Value = $templatecontent;
               $oFCKeditor->Create();
           ?>
      <br />
      News Image: &nbsp;
      <input type="file" id="edit_news_image" name="edit_news_image" class="text-input small-input"> Please Upload Image Size  <input type="hidden" name="oldimage" id="oldimage" value="<?php echo $items['news_image'];?>"/><br />
      News Status: &nbsp;
      
      <input type="checkbox" name="edit_news_status" id="edit_news_status" value="kashif" <?php if ($items['news_status']==1) echo "checked=checked"; ?>/><br />
      
      <input type="submit" class="button" name="submit" value="Update" />&nbsp; <input type="button" value="Cancel" class="button" onclick="document.getElementById('<?php echo $items['news_id'];?>').style.display='none'"  />
      </form>
      </div>
      
      
      
      </td>
      </tr>
    
    PHP:
     
    hallianonline, Sep 16, 2014 IP
  2. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #2
    I assume news_description in your array of items is a textarea of some sort and you are trying to create an instance of FCKeditor for each textarea?

    Something that would be easy to do is to append a number to each textareas and each instance of the editor like so FCKeditor('news_description'.$countvar); and then just adding to it at the end of the loop $countvar++;
     
    Anveto, Sep 18, 2014 IP