duan0821 2017-06-22 10:37
浏览 112
已采纳

如何在php中将数组值从一个函数传递给另一个函数?

I am selecting multiple Id from Page1 and sending to Page2 which is working, Now I have to display all id to function name fake_user_archive for delete. I am getting empty value in the function.

Example: I have id no 1,5,20,50. I selected from Page1 and sending that id to page2. My code will check the email status if the status is 1 it will call the next function which is called as fake_user_archive and there email will delete. but I am not getting any value inside the function. page1.php

This is not my whole code. only for reference.

<?php
while ($stmt->fetch()) {
    echo"<input type='checkbox' name='check_list[]' value='".$id."'>";
}?>

Page2.php

    switch($_GET['function']) {
    case 'checking':checking($conn);break;
    default : redirect('index.php');
    }
    function checking($conn)
    {
    // loop over checked checkboxes
    foreach($_POST['check_list'] as $checkbox) {

        //echo $checkbox;//displaying all id
        $sql_all="SELECT * FROM `request` WHERE Id='".$checkbox."'";
        $result_chk=$conn->query($sql_all);
           if (isset($result_chk->num_rows) > 0) {
               while($row = $result_chk->fetch_assoc()) {
                    $r_email_verify=$row['email_verification'];

               }
           }

           if ($r_email_verify == 1) {
              fake_user_archive($conn);//calling the function but getting empty
           }
else{
other_function();
}

    }//foreach

    }

    function fake_user_archive($conn)
    {
        // how do i get here all my id which is selected from page1.php
        //deactive id here
    }
  • 写回答

1条回答 默认 最新

  • dongzhong8691 2017-06-22 10:46
    关注

    1st : you can pass N number of parameter to function pass it like this

    fake_user_archive($conn,$checkbox);
    

    2nd : function should be

    function fake_user_archive($conn,$checkbox)
    {
       var_dump($checkbox);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划