Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.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_Post_Get - Fatal编程技术网

php处理动态生成的表单

php处理动态生成的表单,php,javascript,post,get,Php,Javascript,Post,Get,我使用php生成一个显示博客/线程项目的html页面,并使用javascript显示/隐藏一些细节。问题是,我正在为每一组隐藏内容生成唯一的ID,其中包含一个表单来处理输入。在处理表单时,我需要知道编辑了哪个博客项目-我想使用$\u POST。我对javascript非常陌生,我想可能有一个解决方案可以在那里使用 我希望帖子将文本保存到mysql数据库中,因此请调用我的一个php函数,告诉我文本是什么,线程ID是什么 下面是php代码snipet,其中$threadDetailItem是一个数组

我使用php生成一个显示博客/线程项目的html页面,并使用javascript显示/隐藏一些细节。问题是,我正在为每一组隐藏内容生成唯一的ID,其中包含一个表单来处理输入。在处理表单时,我需要知道编辑了哪个博客项目-我想使用$\u POST。我对javascript非常陌生,我想可能有一个解决方案可以在那里使用

我希望帖子将文本保存到mysql数据库中,因此请调用我的一个php函数,告诉我文本是什么,线程ID是什么

下面是php代码snipet,其中$threadDetailItem是一个数组,其中包含我的线程数据

   foreach ($threadData as $threadDetailItem)
   {
    // display main line (a bunch of code here ...)


    // append button to edit or delete the post for admin
    if ( isset ($_SESSION['isAdmin']) && $_SESSION['isAdmin'] == 'Y'){
        // edit link opens content, and delete pops up a confirmation box
        $el = sprintf ("editThreadLink_%d", $threadDetailItem['blogThreadId']);
        $ec = sprintf ("editThreadContent_%d", $threadDetailItem['blogThreadId']);
        $link1 = sprintf ("<a id=\"%s\" href=\"javascript:toggle('%s', '%s');\">+</a>", $el, $ec, $el);
        $msg .= sprintf ("<li id=\"field6\">%s</li>\n", $link1);
    } 
    $msg .= "</ul>\n";
    echo $msg;

    // now that the row is printed, lets add the hidden content if admin so they can edit
    if ( isset ($_SESSION['isAdmin']) && $_SESSION['isAdmin'] == 'Y'){
        // hidden content to enable editing of the posting
        $msg = sprintf ("<div id=\"%s\" style=\"display: none\">\n", $ec);
        echo $msg;

        echo "<form name=\"form\" method=\"post\" action=\"\">\n";
        $msg = sprintf ("<textarea id=\"%s\" name=\"%s\">%s</textarea>\n", 
            $ec, $ec, $threadDetailItem['threadTitle']);
        echo $msg;
        $msg = sprintf ("<button type=\"submit\"> %s</button>\n", $lang->get('BLOG POST'));
        echo $msg;
        echo "</form>\n";
        echo "</div>";
    }
}
对于如何处理这一事件的建议,我们深表感谢。提前谢谢


数据中的字段有:blogThreadId、threadTitle、username、createdOn、LastUpdate、displayed not used和threadDetails数组,其中包含发布信息。

我可以使用$\u POST,在隐藏字段中添加ID,以使我的php脚本能够知道正在编辑哪个线程。它正在工作

您要处理什么事件??另外添加示例$threadData数据我正在考虑向我的表单中添加一个隐藏字段,这将使常规post能够知道treadId,这是用户更新字段时发生的事件。$threadData是一个实例,可以在我在问题底部输入的调试函数中打印出来。谢谢。您想在单击按钮时将表单输入值保存到数据库中,对吗?是-我会将值保存到数据库中,然后重新显示页面。我想我可以通过隐藏字段来完成这项工作,并在有效时返回。