提交两次表格

发布于 2024-12-05 23:48:24 字数 857 浏览 0 评论 0原文

我有 PHP 代码,它为每个列表项创建一个带有单选按钮的列表。

$result = mysql_query("SELECT * FROM attitudes WHERE x_axis = '$famID'",$db);
$rowcheck = mysql_num_rows($result);
while ($row_user = mysql_fetch_assoc($result))   

foreach ($row_user as $col=>$val) {
    if ($col != $famID && $col != 'x_axis') {
        list($famname) = mysql_fetch_row(mysql_query("SELECT familyname FROM families WHERE families_ID='$col'",$db));
        echo "col $col famname $famname is val $val.";
        echo "<input type = \"radio\" name = \"whichfam\" value = \"$col\" />";
        echo "</br>";

    }
}

然后我在底部有一个提交按钮(以及整个内容的表单标签),

我想要两个可能的提交。此代码旨在让玩家提高或降低数值。他们单击单选按钮之一,然后选择“升高”或“降低”。然后它应该发布到后端并执行代码以提高或降低该值。我知道如何在 jquery 中执行此操作,但我不知道如何在 PHP 中拥有两个 SUBMIT 按钮。

我该怎么做?

(具体来说,如何让两个提交按钮都起作用,后端代码应该比较简单,$_POST什么的)

I have PHP code which creates a list with radio buttons for each list item.

$result = mysql_query("SELECT * FROM attitudes WHERE x_axis = '$famID'",$db);
$rowcheck = mysql_num_rows($result);
while ($row_user = mysql_fetch_assoc($result))   

foreach ($row_user as $col=>$val) {
    if ($col != $famID && $col != 'x_axis') {
        list($famname) = mysql_fetch_row(mysql_query("SELECT familyname FROM families WHERE families_ID='$col'",$db));
        echo "col $col famname $famname is val $val.";
        echo "<input type = \"radio\" name = \"whichfam\" value = \"$col\" />";
        echo "</br>";

    }
}

Then I have a submit button at the bottom (and form tags for the whole thing)

I want to have two possible submissions. This code is intended to let the player raise or lower a value. They click on one of the radio buttons, and then select "Raise", or "Lower". It should then post to a backend and execute code to either raise or lower that value. I know how to do this in jquery, but I don't know how to have two SUBMIT buttons in PHP.

How can I do this?

(Specifically, how do I make two submission buttons work, the backend code should be relatively simple, $_POST or whatever)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日暮斜阳 2024-12-12 23:48:24

这是您要找的吗?

<button type="submit" name="submit1" value="submit1">submit1</button>
<button type="submit" name="submit2" value="submit2">submit2</button>

然后

if(isset($_POST["submit1"])) {

} else if(isset($_POST["submit2"])) {

}

Is this what you're looking for?

<button type="submit" name="submit1" value="submit1">submit1</button>
<button type="submit" name="submit2" value="submit2">submit2</button>

then

if(isset($_POST["submit1"])) {

} else if(isset($_POST["submit2"])) {

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文