如何将具有共享名称的字段的值插入MySQL


How do I insert value of field with a shared name into MySQL?

我有几个具有共享名称的字段。

我想插入任何有数据(或值)的人。 使用 jQuery 显示和隐藏一次只显示一个具有共享名称的字段。

我尝试在每个字段中使名称相同,如下所示:

mailer_type

我尝试将其制作成这样的数组:

mailer_type[]

我尝试将其制作成这样的数组:

mailer_type[mt]

为了获取帖子数据,我尝试了这个:

$mailer_type = mysql_real_escape_string(htmlspecialchars($_POST['mailer_type']));

为了获取帖子数据,我尝试了这个:

$mailer_type = mysql_real_escape_string(htmlspecialchars($_POST['mailer_type[]']));

为了获取帖子数据,我尝试了这个:

$mailer_type = mysql_real_escape_string(htmlspecialchars($_POST['mailer_type[mt]']));

为了获取帖子数据,我尝试了这个:

$mailer_type = mysql_real_escape_string(htmlspecialchars($_POST['mailer_type']['mt']));

将数据插入数据库,它总是相同的。 没有尝试过不同的事情:

mysql_query("INSERT jobs SET mailer_type='$mailer_type' ") or die(mysql_error());

每次我提交表单时,要么表格列中没有任何东西,要么表格列中没有 0。 未插入字段的实际值。

试试这个:

$mailer_type = mysql_real_escape_string(htmlspecialchars($_REQUEST['mailer_type']));

而不是发布,看看它是否获取了发布数据。