dongtanzhu5417 2013-11-16 22:36 采纳率: 100%
浏览 34

尝试将CKEditor集成到php页面中

I'm trying to integrate CKEditor into my simple CMS. I got it to show up on the page, but it's just above everything. I'm wondering how to get it into the correct spot, below my title textbox? Here is my code:

require_once 'conn.php';
include_once 'ckeditor/ckeditor.php';
$CKEditor = new CKEditor();
$CKEditor->editor('body');
$title= '';
$body= '';
$article= '';
$author_id= '';
if (isset($_GET['a'])
    and $_GET['a'] == 'edit'
    and isset($_GET['article'])
    and $_GET['article']) {
        $sql = "SELECT title, body, author_id FROM cms_articles " .
        "WHERE article_id=" . $_GET['article'];
        $result = mysql_query($sql, $conn) or
            die ('Could not retrieve article data: ' . mysql_error());
        $row = mysql_fetch_array($result);
        $title = $row['title'];
        $body = $row['body'];
        $article = $_GET['article'];
        $author_id = $row['author_id'];
    }
    require_once 'header.php';
?>
<form method="post" action="transact-article.php">
    <h2>Compose Article</h2>
    <p>
        Title: <br />
        <input type="text" class="title" name="title" maxlength="255" value="<?php echo htmlspecialchars($title); ?>" />
    </p>
    <p>
        Body: <br />
        <textarea class="body" name="body" id="body" rows="10" cols="60"><?php echo htmlspecialchars($body); ?></textarea>
    </p>
    <p>
        <?php
            echo '<input type="hidden" name="article" value="' .
            $article . "\" />
";
            if ($_SESSION['access_lvl'] < 2) {
                echo '<input type="hidden" name="author_id" value="' .
                $author_id . "\" />
";
            }
            if ($article) {
                echo '<input type="submit" class="submit" name="action" ' .
                "value=\"Save Changes\" />";
            } else {
                echo '<input type="submit" class="submit" name="action" ' .
                "value=\"Submit New Article\" />";
            }
        ?>
    </p>
</form>
  • 写回答

1条回答 默认 最新

  • douxin5953 2013-11-18 21:32
    关注

    Personally I don't think you need the PHP library. Just add

    <div contenteditable="true">
        Editable text
    </div>
    

    as your editable and then just the script to get it running:

    <script type="text/javascript" src="/path/to/ckeditor/ckeditor.js"></script>
    

    That said, you may be able to pass the id of your textarea to the PHP library. To avoid confusion with the body tag, rename the id and name of this control to editable_content or similar. And as I mention above, try using a div instead.

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向