如何在单个php页面中调用多个sql存储过程

问题描述

我正在尝试在同一页面中调用两个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'];是第二个过程的输出 现在,问题是我正在获取<?php echo number_format($total_left_1); ?>的输出,而无法得到<?php echo number_format($total_right_1); ?>的输出,它只显示Notice: Undefined index: total_right_1 in G:\XampNew\htdocs 请帮助我

解决方法

您需要两次使用mysqli_fetch_array

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...