doujiyuan0211 2015-07-08 11:59
浏览 30

如何运行带有作为参数传递的复选框值数组的函数?

So I'm wanting to run a function EVERY TIME a user clicks the btnChangeCat button...Im having trouble and I'm really not sure how to get it to work!

Im trying to run showCategory($_POST['chkCat'], 1)[0];and pass it the array of checked checkboxes when the user clicks the btnChangeCat button. Im not sure why this isn't working??

I've literally searched everywhere for a WORKING solution but can't find one that will work when passing the values to a function!

    $showVideos = showCategory($categories, 1)[0];
    $rowLength = showCategory($categories, 1)[3];
    $likes = showCategory($categories, 1)[1];
    $dislikes = showCategory($categories, 1)[2];
?>
<main>

    <div class='controller-wrap'>
        <div class='content-wrap'>
        <h3>Category: </h3>hp

            <form action='most-liked.php' method='post'>
                <?php
                    $allCategories = ["All", "Sport", "Automotive", "Comedy", "Misc", "Surfing"];
                    $htmlOutput = "";
                    $i=0;
                        for($i;$i<sizeof($allCategories);$i++)
                        {
                            if($allCategories[$i] == "Surfing"){
                                $htmlOutput .= "<input selected='selected' type='checkbox' name='chkCat[]' value='".$allCategories[$i]."'/>";
                            }
                            else{
                                $htmlOutput .= "<input type='checkbox' name='chkCat[]' value='".$allCategories[$i]."'/>";
                            }
                        }   
                    echo $htmlOutput;
                ?>

            </form>
            <br />
        if(isset($_POST['chkCat'])){
            if(is_array($_POST['chkCat'])) {
                foreach($_POST['chkCat'] as $value){
                  echo $value;
                }
            }else{
                    $value = $_POST['chkCat'];
                    echo $value;
                }
                // showCategory($_POST['chkCat'], 1)[0];
        }
        isset($_POST['btnChangeCat'])){
            // //How can I run this function with the array of CHECKBOXES??
            showCategory($_POST['chkCat'], 1)[0];
        }
        ?>
        <input type='submit' value='CHANGE CATEGORIES' class='btnlike btnLike' name='btnChangeCat'/>
    </div>
</main>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?