【问题标题】:how to call multiple sql stored procedure in a single php page如何在单个php页面中调用多个sql存储过程
【发布时间】:2020-09-08 09:54:22
【问题描述】:

我正在尝试在同一页面中调用两个 sql 存储过程 我试过的是

                  mysqli_query($con,"DROP PROCEDURE IF EXISTS count_nodes_all_1 "); 
                  mysqli_query($con,"CREATE PROCEDURE count_nodes_all_1()
                               BEGIN
                                  CALL count_nodes_left_1('id-1',750);
                                  CALL count_nodes_right_1('id-2',750);
                                END"); 

                          $qry = "CALL count_nodes_all_1";                     

   if ($result = mysqli_query($con, $qry)) 
                  {
                    while ($row = mysqli_fetch_array($result)) 
                    {
                          
                          
                          
                             $total_left_1 = $row['total_left_1'];
                             $total_right_1 = $row['total_right_1'];
                          
?>
      <th scope="row"><?php echo number_format($total_left_1); ?></th>
      <th scope="row"><?php echo number_format($total_right_1); ?></th>

这里$total_left_1 = $row['total_left_1']; 是第一个过程的输出,$total_right_1 = $row['total_right_1']; 是第二个过程的输出 现在,问题是我得到了&lt;?php echo number_format($total_left_1); ?&gt; 的输出并且无法得到&lt;?php echo number_format($total_right_1); ?&gt; 的输出它只是显示Notice: Undefined index: total_right_1 in G:\XampNew\htdocs 请在这方面帮助我

【问题讨论】:

    标签: php mysql stored-procedures


    【解决方案1】:

    你需要使用 mysqli_fetch_array 两次

    【讨论】:

    • 我是初学者,看不懂。请详细说明如何使用mysqli_fetch_array两次
    猜你喜欢
    • 2021-09-24
    • 2021-05-21
    • 2014-06-05
    • 1970-01-01
    • 1970-01-01
    • 2012-02-29
    • 2013-03-04
    • 1970-01-01
    • 2012-03-07
    相关资源
    最近更新 更多