Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 创建包含可保存和可检索内容的粘性页面的最佳方法是什么?_Php_Javascript_Jquery_Mysql - Fatal编程技术网

Php 创建包含可保存和可检索内容的粘性页面的最佳方法是什么?

Php 创建包含可保存和可检索内容的粘性页面的最佳方法是什么?,php,javascript,jquery,mysql,Php,Javascript,Jquery,Mysql,我看了一下和,虽然它们看起来都很漂亮,但它们缺少一些我想要的元素。我还没有找到允许特定用户修改他们创建的胶粘物的方法,也没有找到将他们的胶粘物保存到数据库中的好方法。我是,并且希望继续使用php、mysql和jquery。我认为,在第一个链接中,我可以将创建的图像保存到一个文件夹中,并将url保存到该数据库中,但我无法返回并允许用户更改粘贴内容。对于第二个链接,似乎根本不支持保存粘性。我还想创建一个函数,在这个函数中,向留言板(让每个人都能看到)添加胶粘物是以一种看起来很自然的随机方式进行的。对

我看了一下和,虽然它们看起来都很漂亮,但它们缺少一些我想要的元素。我还没有找到允许特定用户修改他们创建的胶粘物的方法,也没有找到将他们的胶粘物保存到数据库中的好方法。我是,并且希望继续使用php、mysql和jquery。我认为,在第一个链接中,我可以将创建的图像保存到一个文件夹中,并将url保存到该数据库中,但我无法返回并允许用户更改粘贴内容。对于第二个链接,似乎根本不支持保存粘性。我还想创建一个函数,在这个函数中,向留言板(让每个人都能看到)添加胶粘物是以一种看起来很自然的随机方式进行的。对这两个问题有什么想法吗?

您看过其中的任何代码吗?我很快地看了一眼jStickyNote

基本上,“便笺”是一个css样式的文本区域(由div元素包围)

如果您希望用户能够保存便笺/编辑过去的便笺,我建议您:

  • 在每个便笺上添加一些按钮,上面写着“保存”或类似的意思
  • 当用户单击“保存”按钮时,您需要从特定的textarea元素中获取文本,然后将该文本保存到数据库中
话虽如此,您可能需要设计某种数据库,其中包含用户表和sticknote表。sticknote表可以具有用户表的外键。 您还需要向站点添加某种登录功能,然后为经过身份验证的用户加载正确的便笺


祝你好运

您可以查看-该代码已由google appengine团队发布。

很抱歉没有详细说明,但您可以修改插件代码,以便在使用$.ajax()单击保存按钮(或移动框,甚至在keyup上)时加载php脚本,将注释的水平和垂直位置以及内容(比如,$(“#note content”).text())传递给它,并让脚本使用MySQL查询将这些内容插入数据库。只需序列化数据并将其发送出去。如果你想让你的用户有多个笔记,但从一个开始,这会变得更复杂。你到底在哪里挂断电话?我会更具体一些,但我不确定你已经知道了什么


我之前在考虑将此功能添加到我正在开发的应用程序中。问题是,我不喜欢那些插件。但是写自己的应该很简单。如果您需要特别的帮助,请告诉我。

这里有一些javascript应该可以帮助您:

// Called when the edit (A) button is pressed
function edit(event, editButton)
{
    // Get existing title and change element to textarea
    var stickyTitle = $(editButton).parent().find('p.stickyTitle');
    var textareaTitle = $(document.createElement('textarea')).addClass('textareaTitle');
    $(textareaTitle).text(stickyTitle.html());

    // Get existing description and change element to textarea
    var stickyDescription = $(editButton).parent().find('p.stickyDescription');
    var textareaDescription = $(document.createElement('textarea')).addClass('textareaDescription');
    $(textareaDescription).text(stickyDescription.html());

    // Create save button
    var saveButton = $(document.createElement('div')).addClass('jSticky-create');                    

    // Add save button, then replace title, then replace description, then remove edit button
    $(editButton).before(saveButton);
    $(editButton).parent().find('p.stickyTitle').before(textareaTitle).remove();
    $(editButton).parent().find('p.stickyDescription').before(textareaDescription).remove();
    $(editButton).remove();

    // Set description textarea focus and set button actions
    textareaTitle.focus();
    setActions();
}

// Called when the save (tick) button is pressed
function save(event, saveButton)
{
    // Get existing title and change element to paragraph
    var textareaTitle = $(saveButton).parent().find('textarea.textareaTitle');
    var stickyTitle = $(document.createElement('p')).addClass('stickyTitle');
    var newTitleValue = textareaTitle.val();
    $(stickyTitle).html(newTitleValue);

    // Get existing description and change element to paragraph
    var textareaDescription = $(saveButton).parent().find('textarea.textareaDescription');
    var stickyDescription = $(document.createElement('p')).addClass('stickyDescription');
    var newDescriptionValue = textareaDescription.val();
    $(stickyDescription).html(newDescriptionValue);

    // Create edit button
    var editButton = $(document.createElement('div')).addClass('jSticky-edit');

    // Add edit button, then replace title, then replace description, then remove save button
    $(saveButton).before(editButton);
    $(saveButton).parent().find('textarea.textareaTitle').before(stickyTitle).remove();
    $(saveButton).parent().find('textarea.textareaDescription').before(stickyDescription).remove();
    $(saveButton).remove();

    // Set button actions
    setActions();

    // Add the object to the ads div
    $('#ads').append(object);

    // Update your database here
    // by calling the saveAd.php
}

function setActions()
{

    // call these after changes are made to anything
    $('.jSticky-create').unbind('click').click(function(e)
    {
        save(e, this);
    });

    $('.jSticky-edit').unbind('click').click(function(e)
    {
        edit(e, this);
    });

    $('.jSticky-delete').unbind('click').click(function(e)
    {
        remove(e, this);
    });
}

function remove(event, deleteButton)
{
    var stickyMaster = $(deleteButton).parent();
    $(stickyMaster).remove();
    //then call savead.php with delete parameter
}

如果您使用该页面上的代码,请确保您已修复该代码,使其在IE8中正常工作。:-)我希望每个用户都有多个粘滞,而对于其他所有用户(未登录)来说,每个粘滞都是在网格布局中创建的。网格可以显示一个带有文章标题和日期的小粘滞,然后单击放大到粘滞的较大图像,其中包含描述以及指向图像阴影框或其他内容的链接。。。我不知道这两个插件是否都支持将图像放入“粘滞”中,但也许我可以使用锚定标签打开一个阴影盒。这需要一些工作。阅读jQuery文档并构建一些简单的测试页面来来回传递一些数据。查看描述如何序列化数据、使用ajax和使用事件的内容。您需要(通过POST或GET)将坐标、标题和正文传递给一个脚本,该脚本将插入数据库。您需要一个MySQL表,其中至少有一列指定哪个用户在您的x、y、title、body旁边设置了粘滞,并且您可能应该将其与一个用户表关联,以便您可以显示关于发布者的信息并允许编辑/删除。这有什么帮助吗?是的,有一点,jStickyNotes中没有编辑功能,所以我想我可能还需要扩展插件。如果我只希望某些用户可以编辑某些帖子,我不确定这将如何进行。请阅读PHP会话,并在更新行时向WHERE子句添加一个条件。如“WHERE id=$sticky\u id和posted\u by=$\u SESSION[USER\u id]”所示。我首先推荐O'Reilly的“PHP食谱”。一步一个脚印。你不必同时做每件事。