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);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 铜与钢双金属板叠加在一起每种材料300mm长,18mm宽,4mm厚一端固定并加热至80℃,当加热端温度保持不变时另一端的稳态温度。ansys
  • ¥15 django5安装失败
  • ¥60 ios系统storm sniffer 写入http规则加密如何破解?
  • ¥15 Java与Hbase相关问题
  • ¥15 后缀 crn 游戏文件提取资源
  • ¥15 ANSYS分析简单钎焊问题
  • ¥20 bash代码推送不上去 git fetch origin master #失败了
  • ¥15 LOL外服加入了反作弊系统,现在游戏录像rofl文件离线都无法打开
  • ¥15 在centos7安装conda
  • ¥15 c#调用yolo3 dll文件获取的数据对不上