条件式获取姓名

发布于 2024-12-21 10:44:39 字数 1801 浏览 0 评论 0原文

我正在做一个条件形式,据我所知,一切都是正确的,除了它不能正常工作。我试图将我的值传递到 if 语句中,但它只是没有得到它们,它一直回响我的 else 语句。

这就是我所拥有的

    <form action="" method="post">
<select name="optionType" onChange="this.form.submit();">
<option value="Ben">Ben</option>
<option value="John">John</option>
<option value="Matt">Matt</option>
</select>
</form>

<table>

<? 
for($x=2; $x<=count($excel->sheets[0]["cells"]); $x++) {
    $date = $excel->sheets[0]["cells"][$x][1];
    $user = $excel->sheets[0]["cells"][$x][2];
    $type = $excel->sheets[0]["cells"][$x][3];
    $keywords = $excel->sheets[0]["cells"][$x][4];
    $keywordpage = $excel->sheets[0]["cells"][$x][5];
    $urls = $excel->sheets[0]["cells"][$x][6];
    $sitepr = $excel->sheets[0]["cells"][$x][7];

    echo "\t<tr>\n";
    if($user == $_POST['optionType']) {
        echo "<td>";
    echo $date = $excel->sheets[0]["cells"][$x][1];
    echo "</td>\n";

    echo "<td>";
    echo $user = $excel->sheets[0]["cells"][$x][2];
    echo "</td>\n";

    echo "<td>";
    echo $type = $excel->sheets[0]["cells"][$x][3];
    echo "</td>\n";

    echo "<td>";
    echo $keywords = $excel->sheets[0]["cells"][$x][4];
    echo "</td>\n";

    echo "<td>";
    echo $keywordpage = $excel->sheets[0]["cells"][$x][5];
    echo "</td>\n";

    echo "<td>";
    echo $urls = $excel->sheets[0]["cells"][$x][6];
    echo "</td>\n";

    echo "<td>";
    echo $sitepr = $excel->sheets[0]["cells"][$x][7];
    echo "</td>\n";
    }else{
    echo 'Nothing at this time';
    }
    echo "\t</tr>\n";
}

    ?>
    </table>

任何帮助表示赞赏 谢谢

Im doing a conditional form and as far as I can tell everything is correct except its just not working correctly. im trying to pass my values into a if statement and its just not getting them, it keeps echoing out my else statement.

This is what I have

    <form action="" method="post">
<select name="optionType" onChange="this.form.submit();">
<option value="Ben">Ben</option>
<option value="John">John</option>
<option value="Matt">Matt</option>
</select>
</form>

<table>

<? 
for($x=2; $x<=count($excel->sheets[0]["cells"]); $x++) {
    $date = $excel->sheets[0]["cells"][$x][1];
    $user = $excel->sheets[0]["cells"][$x][2];
    $type = $excel->sheets[0]["cells"][$x][3];
    $keywords = $excel->sheets[0]["cells"][$x][4];
    $keywordpage = $excel->sheets[0]["cells"][$x][5];
    $urls = $excel->sheets[0]["cells"][$x][6];
    $sitepr = $excel->sheets[0]["cells"][$x][7];

    echo "\t<tr>\n";
    if($user == $_POST['optionType']) {
        echo "<td>";
    echo $date = $excel->sheets[0]["cells"][$x][1];
    echo "</td>\n";

    echo "<td>";
    echo $user = $excel->sheets[0]["cells"][$x][2];
    echo "</td>\n";

    echo "<td>";
    echo $type = $excel->sheets[0]["cells"][$x][3];
    echo "</td>\n";

    echo "<td>";
    echo $keywords = $excel->sheets[0]["cells"][$x][4];
    echo "</td>\n";

    echo "<td>";
    echo $keywordpage = $excel->sheets[0]["cells"][$x][5];
    echo "</td>\n";

    echo "<td>";
    echo $urls = $excel->sheets[0]["cells"][$x][6];
    echo "</td>\n";

    echo "<td>";
    echo $sitepr = $excel->sheets[0]["cells"][$x][7];
    echo "</td>\n";
    }else{
    echo 'Nothing at this time';
    }
    echo "\t</tr>\n";
}

    ?>
    </table>

Any help is appreciated
thank you

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

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

发布评论

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

评论(1

笑看君怀她人 2024-12-28 10:44:39

看起来问题出在 $_POST['userinfo'] 上。您的选择框未命名为userinfo。它被命名为optionType。所以你永远不会从你的表单中传递用户。

It looks like the issue is this $_POST['userinfo']. Your select box isn't named userinfo. It's named optionType. So you never get a user passed from your form.

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